Merge "Add MobileRadio/Gnss MeasuredBatteryConsumpter methods to FakeUid" into sc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 30f181a..71941d1 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -19,6 +19,8 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.HARDWARE_TEST" />
@@ -105,6 +107,7 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.READ_DREAM_STATE" />
<uses-permission android:name="android.permission.READ_DREAM_SUPPRESSION" />
+ <uses-permission android:name="android.permission.MANAGE_APP_HIBERNATION" />
<application android:label="@string/settings_label"
android:icon="@drawable/ic_launcher_settings"
@@ -396,12 +399,15 @@
android:exported="true"
android:permission="android.permission.NETWORK_STACK"
android:theme="@*android:style/Theme.DeviceDefault.Dialog.Alert.DayNight">
+ <!-- TODO: Consider removing below two intent filters.
+ It seems like below two intent filters can be removed because when the notification
+ is clicked, this activity will be launched anyway. -->
<intent-filter>
- <action android:name="android.net.conn.PROMPT_UNVALIDATED" />
+ <action android:name="android.net.action.PROMPT_UNVALIDATED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
- <action android:name="android.net.conn.PROMPT_LOST_VALIDATION" />
+ <action android:name="android.net.action.PROMPT_LOST_VALIDATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -3185,6 +3191,33 @@
android:value="com.android.settings.applications.appinfo.ManageExternalStorageDetails" />
</activity>
+ <activity
+ android:name="Settings$MediaManagementAppsActivity"
+ android:exported="true"
+ android:label="@string/media_management_apps_title">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.REQUEST_MANAGE_MEDIA" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.applications.manageapplications.ManageApplications" />
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
+ <activity
+ android:name="Settings$AppMediaManagementAppsActivity"
+ android:exported="true"
+ android:label="@string/media_management_apps_title">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.REQUEST_MANAGE_MEDIA" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="package" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.applications.appinfo.MediaManagementAppsDetails" />
+ </activity>
+
<!-- Keep compatibility with old WebView-picker implementation -->
<activity-alias android:name=".WebViewImplementation"
android:targetActivity="Settings$WebViewAppPickerActivity"
diff --git a/res/drawable/accessibility_magnification_full_screen.png b/res/drawable/accessibility_magnification_full_screen.png
deleted file mode 100644
index 2e87ab8..0000000
--- a/res/drawable/accessibility_magnification_full_screen.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/accessibility_magnification_full_screen.xml b/res/drawable/accessibility_magnification_full_screen.xml
new file mode 100644
index 0000000..09d1a7e
--- /dev/null
+++ b/res/drawable/accessibility_magnification_full_screen.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="77dp"
+ android:height="134dp"
+ android:viewportWidth="77"
+ android:viewportHeight="134">
+ <path
+ android:pathData="M7.4,1.1L69.6,1.1A6.3,6.3 0,0 1,75.9 7.4L75.9,126.6A6.3,6.3 0,0 1,69.6 132.9L7.4,132.9A6.3,6.3 0,0 1,1.1 126.6L1.1,7.4A6.3,6.3 0,0 1,7.4 1.1z"
+ android:strokeWidth="1.8"
+ android:fillColor="#F2F3F4"
+ android:strokeColor="#DADCE0"/>
+ <group>
+ <clip-path
+ android:pathData="M7.4,1.1L69.6,1.1A6.3,6.3 0,0 1,75.9 7.4L75.9,126.6A6.3,6.3 0,0 1,69.6 132.9L7.4,132.9A6.3,6.3 0,0 1,1.1 126.6L1.1,7.4A6.3,6.3 0,0 1,7.4 1.1z"/>
+ <path
+ android:pathData="M10.442,4.948L67.167,4.948A5.4,5.4 0,0 1,72.567 10.348L72.567,123.548A5.4,5.4 0,0 1,67.167 128.948L10.442,128.948A5.4,5.4 0,0 1,5.042 123.548L5.042,10.348A5.4,5.4 0,0 1,10.442 4.948z"
+ android:fillColor="#ffffff"/>
+ <group>
+ <clip-path
+ android:pathData="M10.442,4.948L67.167,4.948A5.4,5.4 0,0 1,72.567 10.348L72.567,123.548A5.4,5.4 0,0 1,67.167 128.948L10.442,128.948A5.4,5.4 0,0 1,5.042 123.548L5.042,10.348A5.4,5.4 0,0 1,10.442 4.948z"/>
+ <path
+ android:pathData="M13,5L65,5A8,8 0,0 1,73 13L73,120A8,8 0,0 1,65 128L13,128A8,8 0,0 1,5 120L5,13A8,8 0,0 1,13 5z"
+ android:strokeLineJoin="bevel"
+ android:strokeWidth="10"
+ android:fillColor="#00000000"
+ android:strokeColor="#F29900"/>
+ <path
+ android:pathData="M51.077,14V18.314H56.612L50,24.958L53.037,28L59.692,21.334V26.921H64V14H51.077Z"
+ android:fillColor="#F29900"/>
+ <path
+ android:pathData="M25.963,104L19.308,110.655V105.077H15V118H27.923V113.692H22.366L29,107.037L25.963,104Z"
+ android:fillColor="#F29900"/>
+ </group>
+ </group>
+</vector>
diff --git a/res/drawable/accessibility_magnification_switch.xml b/res/drawable/accessibility_magnification_switch.xml
new file mode 100644
index 0000000..21e0cef
--- /dev/null
+++ b/res/drawable/accessibility_magnification_switch.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="77dp"
+ android:height="134dp"
+ android:viewportWidth="77"
+ android:viewportHeight="134">
+ <path
+ android:pathData="M7.4,1.1L69.6,1.1A6.3,6.3 0,0 1,75.9 7.4L75.9,126.6A6.3,6.3 0,0 1,69.6 132.9L7.4,132.9A6.3,6.3 0,0 1,1.1 126.6L1.1,7.4A6.3,6.3 0,0 1,7.4 1.1z"
+ android:strokeWidth="1.8"
+ android:fillColor="#F2F3F4"
+ android:strokeColor="#DADCE0"/>
+ <group>
+ <clip-path
+ android:pathData="M7.4,1.1L69.6,1.1A6.3,6.3 0,0 1,75.9 7.4L75.9,126.6A6.3,6.3 0,0 1,69.6 132.9L7.4,132.9A6.3,6.3 0,0 1,1.1 126.6L1.1,7.4A6.3,6.3 0,0 1,7.4 1.1z"/>
+ <path
+ android:pathData="M10.442,4.948L67.167,4.948A5.4,5.4 0,0 1,72.567 10.348L72.567,123.548A5.4,5.4 0,0 1,67.167 128.948L10.442,128.948A5.4,5.4 0,0 1,5.042 123.548L5.042,10.348A5.4,5.4 0,0 1,10.442 4.948z"
+ android:fillColor="#ffffff"/>
+ <group>
+ <clip-path
+ android:pathData="M10.442,4.948L67.167,4.948A5.4,5.4 0,0 1,72.567 10.348L72.567,123.548A5.4,5.4 0,0 1,67.167 128.948L10.442,128.948A5.4,5.4 0,0 1,5.042 123.548L5.042,10.348A5.4,5.4 0,0 1,10.442 4.948z"/>
+ <path
+ android:pathData="M39,94h24v24h-24z"
+ android:fillColor="#000000"
+ android:fillAlpha="0.7"/>
+ <path
+ android:pathData="M51.414,98.138H45.138C44.033,98.138 43.138,99.033 43.138,100.138V112.689C43.138,113.794 44.033,114.689 45.138,114.689H57.69C58.794,114.689 59.69,113.794 59.69,112.689L59.69,106.414H57.69L57.69,112.689L45.138,112.689V100.138H51.414V98.138ZM49.414,108.414H48.448V109.379H49.414V108.414ZM48.448,106.414H46.448V108.414V109.379V111.379H48.448H49.414H51.414V109.379V108.414V106.414H49.414H48.448ZM55.891,103.103L58.035,103.103V104.758L53.069,104.758V99.793L54.724,99.793V101.936L58.275,98.378L59.45,99.553L55.891,103.103Z"
+ android:fillColor="#ffffff"
+ android:fillType="evenOdd"/>
+ <path
+ android:pathData="M13,5L65,5A8,8 0,0 1,73 13L73,120A8,8 0,0 1,65 128L13,128A8,8 0,0 1,5 120L5,13A8,8 0,0 1,13 5z"
+ android:strokeLineJoin="bevel"
+ android:strokeWidth="10"
+ android:fillColor="#00000000"
+ android:strokeColor="#F29900"/>
+ </group>
+ </group>
+</vector>
diff --git a/res/drawable/accessibility_magnification_window_screen.png b/res/drawable/accessibility_magnification_window_screen.png
deleted file mode 100644
index a7f2a25..0000000
--- a/res/drawable/accessibility_magnification_window_screen.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/accessibility_magnification_window_screen.xml b/res/drawable/accessibility_magnification_window_screen.xml
new file mode 100644
index 0000000..d7e164c
--- /dev/null
+++ b/res/drawable/accessibility_magnification_window_screen.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="77dp"
+ android:height="134dp"
+ android:viewportWidth="77"
+ android:viewportHeight="134">
+ <path
+ android:pathData="M7.4,1.1L69.6,1.1A6.3,6.3 0,0 1,75.9 7.4L75.9,126.6A6.3,6.3 0,0 1,69.6 132.9L7.4,132.9A6.3,6.3 0,0 1,1.1 126.6L1.1,7.4A6.3,6.3 0,0 1,7.4 1.1z"
+ android:strokeWidth="1.8"
+ android:fillColor="#F2F3F4"
+ android:strokeColor="#DADCE0"/>
+ <group>
+ <clip-path
+ android:pathData="M7.4,1.1L69.6,1.1A6.3,6.3 0,0 1,75.9 7.4L75.9,126.6A6.3,6.3 0,0 1,69.6 132.9L7.4,132.9A6.3,6.3 0,0 1,1.1 126.6L1.1,7.4A6.3,6.3 0,0 1,7.4 1.1z"/>
+ <path
+ android:pathData="M10.442,4.948L67.167,4.948A5.4,5.4 0,0 1,72.567 10.348L72.567,123.548A5.4,5.4 0,0 1,67.167 128.948L10.442,128.948A5.4,5.4 0,0 1,5.042 123.548L5.042,10.348A5.4,5.4 0,0 1,10.442 4.948z"
+ android:fillColor="#ffffff"/>
+ <group>
+ <clip-path
+ android:pathData="M10.442,4.948L67.167,4.948A5.4,5.4 0,0 1,72.567 10.348L72.567,123.548A5.4,5.4 0,0 1,67.167 128.948L10.442,128.948A5.4,5.4 0,0 1,5.042 123.548L5.042,10.348A5.4,5.4 0,0 1,10.442 4.948z"/>
+ <path
+ android:pathData="M15,47L64,47A2,2 0,0 1,66 49L66,84A2,2 0,0 1,64 86L15,86A2,2 0,0 1,13 84L13,49A2,2 0,0 1,15 47z"
+ android:strokeLineJoin="bevel"
+ android:strokeWidth="5"
+ android:fillColor="#00000000"
+ android:strokeColor="#F29900"/>
+ <path
+ android:pathData="M47.077,53V57.314H52.612L46,63.958L49.037,67L55.692,60.334V65.921H60V53H47.077Z"
+ android:fillColor="#F29900"/>
+ <path
+ android:pathData="M29.963,66L23.308,72.655V67.077H19V80H31.923V75.692H26.366L33,69.037L29.963,66Z"
+ android:fillColor="#F29900"/>
+ </group>
+ </group>
+</vector>
diff --git a/res/drawable/ic_homepage_search.xml b/res/drawable/ic_homepage_search.xml
index 3895b6b..3da1cc7 100644
--- a/res/drawable/ic_homepage_search.xml
+++ b/res/drawable/ic_homepage_search.xml
@@ -20,7 +20,7 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
- android:tint="?android:attr/colorAccent">
+ android:tint="?android:attr/textColorSecondary">
<path
android:fillColor="#FF000000"
android:pathData="M20.49,19l-5.73,-5.73C15.53,12.2 16,10.91 16,9.5C16,5.91 13.09,3 9.5,3S3,5.91 3,9.5C3,13.09 5.91,16 9.5,16c1.41,0 2.7,-0.47 3.77,-1.24L19,20.49L20.49,19zM5,9.5C5,7.01 7.01,5 9.5,5S14,7.01 14,9.5S11.99,14 9.5,14S5,11.99 5,9.5z"/>
diff --git a/res/drawable/ic_refresh_24dp.xml b/res/drawable/ic_refresh_24dp.xml
deleted file mode 100644
index 9b78fcd..0000000
--- a/res/drawable/ic_refresh_24dp.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2021 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24"
- android:viewportHeight="24"
- android:tint="?android:attr/colorAccent">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M13,9v2h7V4h-2v2.74C16.53,5.07 14.4,4 12,4c-2.21,0 -4.21,0.9 -5.66,2.34S4,9.79 4,12c0,4.42 3.58,8 8,8 2.21,0 4.21,-0.9 5.66,-2.34l-1.42,-1.42C15.15,17.33 13.65,18 12,18c-3.31,0 -6,-2.69 -6,-6 0,-1.65 0.67,-3.15 1.76,-4.24C8.85,6.67 10.35,6 12,6c2.21,0 4.15,1.21 5.19,3H13z"/>
-</vector>
diff --git a/res/drawable/ic_repair_24dp.xml b/res/drawable/ic_repair_24dp.xml
new file mode 100644
index 0000000..da351fc
--- /dev/null
+++ b/res/drawable/ic_repair_24dp.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/black"
+ android:pathData="M12,5c3.53,0 6.44,2.61 6.93,6h2.02c-0.5,-4.5 -4.31,-8 -8.95,-8c-4.97,0 -9,4.03 -9,9c0,3.48 1.98,6.5 4.87,8H5v2h6v-6H9v2.33C6.64,17.2 5,14.79 5,12C5,8.13 8.13,5 12,5z"/>
+ <path
+ android:fillColor="@android:color/black"
+ android:pathData="M22.16,16.5c0,1.93 -1.57,3.5 -3.5,3.5c-0.41,0 -0.8,-0.08 -1.16,-0.21l-2.34,2.33L13.04,20l2.33,-2.34c-0.13,-0.36 -0.21,-0.75 -0.21,-1.16c0,-1.93 1.57,-3.5 3.5,-3.5c0.58,0 1.12,0.16 1.6,0.41l-2.7,2.7l1.49,1.49l2.7,-2.7C22,15.38 22.16,15.92 22.16,16.5z"/>
+</vector>
diff --git a/res/drawable/ic_warning_circle_24dp.xml b/res/drawable/ic_warning_circle_24dp.xml
new file mode 100644
index 0000000..54e2ab4
--- /dev/null
+++ b/res/drawable/ic_warning_circle_24dp.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="?android:attr/colorError"
+ android:pathData="M11,15h2v2h-2v-2zM11,7h2v6h-2L11,7zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
+</vector>
diff --git a/res/layout/accessibility_edit_magnification_mode.xml b/res/layout/accessibility_edit_magnification_mode.xml
deleted file mode 100644
index e4f3132..0000000
--- a/res/layout/accessibility_edit_magnification_mode.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License
- -->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/container_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scrollbarStyle="outsideOverlay">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="24dp">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/accessibility_magnification_area_settings_message"
- android:textAppearance="?android:attr/textAppearanceListItemSecondary"
- android:textColor="?android:attr/textColorSecondary"
- android:layout_marginBottom="24dp"/>
-
- <include
- android:id="@+id/magnify_full_screen"
- layout="@layout/accessibility_edit_shortcut_component"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="32dp" />
-
- <include
- android:id="@+id/magnify_window_screen"
- layout="@layout/accessibility_edit_shortcut_component" />
-
- </LinearLayout>
-
-</ScrollView>
diff --git a/res/layout/accessibility_edit_shortcut_component.xml b/res/layout/accessibility_edit_shortcut_component.xml
index 0ccc88d..0d3324f 100644
--- a/res/layout/accessibility_edit_shortcut_component.xml
+++ b/res/layout/accessibility_edit_shortcut_component.xml
@@ -55,8 +55,8 @@
<ImageView
android:id="@+id/image"
- android:layout_width="176dp"
- android:layout_height="176dp"
+ android:layout_width="@dimen/accessibility_imageview_size"
+ android:layout_height="@dimen/accessibility_imageview_size"
android:layout_marginStart="44dp"
android:scaleType="fitCenter" />
diff --git a/res/layout/accessibility_magnification_mode_header.xml b/res/layout/accessibility_magnification_mode_header.xml
new file mode 100644
index 0000000..e476553
--- /dev/null
+++ b/res/layout/accessibility_magnification_mode_header.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="?android:attr/dialogPreferredPadding">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/accessibility_magnification_area_settings_message"
+ android:textSize="16sp"
+ style="?android:attr/textAppearanceMedium"
+ android:textColor="?android:attr/textColorAlertDialogListItem"/>
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/dialog_single_radio_choice_list_item.xml b/res/layout/dialog_single_radio_choice_list_item.xml
new file mode 100644
index 0000000..5842528
--- /dev/null
+++ b/res/layout/dialog_single_radio_choice_list_item.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<com.android.settings.widget.CheckableRelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="?android:attr/selectableItemBackground"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/dialogPreferredPadding"
+ android:paddingBottom="12dp"
+ android:paddingTop="12dp">
+
+ <RadioButton
+ android:id="@+id/radioButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentTop="true"
+ android:clickable="false"
+ android:focusable="false" />
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@id/radioButton"
+ android:layout_marginStart="8dp"
+ android:layout_toEndOf="@+id/radioButton"
+ android:gravity="center_vertical|start"
+ style="?android:attr/textAppearanceMedium"
+ android:textSize="16sp" />
+
+ <TextView
+ android:id="@+id/summary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+ android:layout_marginTop="8dp"
+ android:layout_alignLeft="@id/title"
+ android:layout_below="@id/title" />
+
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="@dimen/accessibility_imageview_size"
+ android:layout_height="@dimen/accessibility_imageview_size"
+ android:layout_marginTop="16dp"
+ android:scaleType="fitStart"
+ android:layout_alignLeft="@id/title"
+ android:layout_below="@id/summary"/>
+</com.android.settings.widget.CheckableRelativeLayout>
\ No newline at end of file
diff --git a/res/layout/horizontal_preference.xml b/res/layout/horizontal_preference.xml
index 9358cff..e50fc3f 100644
--- a/res/layout/horizontal_preference.xml
+++ b/res/layout/horizontal_preference.xml
@@ -22,7 +22,7 @@
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:orientation="horizontal"
- android:paddingStart="@dimen/preference_no_icon_padding_start"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<TextView
diff --git a/res/layout/one_handed_header.xml b/res/layout/one_handed_header.xml
index 2104e40..3fa8183 100644
--- a/res/layout/one_handed_header.xml
+++ b/res/layout/one_handed_header.xml
@@ -21,7 +21,7 @@
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:scaleType="centerCrop"
+ android:scaleType="centerInside"
android:cropToPadding="true"
android:src="@drawable/one_handed_guideline"
android:contentDescription="@null" />
diff --git a/res/layout/preference_widget_warning.xml b/res/layout/preference_widget_warning.xml
new file mode 100644
index 0000000..ea54afe
--- /dev/null
+++ b/res/layout/preference_widget_warning.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- Warning button -->
+<ImageView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/warning_button"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:paddingStart="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:background="?android:attr/selectableItemBackground"
+ android:scaleType="center"
+ android:src="@drawable/ic_warning_circle_24dp"
+ android:contentDescription="@string/warning_button_text" />
diff --git a/res/layout/search_bar.xml b/res/layout/search_bar.xml
index 63f1c95..7cdf04d 100644
--- a/res/layout/search_bar.xml
+++ b/res/layout/search_bar.xml
@@ -19,10 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/search_bar_margin"
- android:layout_marginStart="@dimen/search_bar_margin"
- android:layout_marginEnd="@dimen/search_bar_margin"
- android:layout_marginBottom="@dimen/search_bar_margin_bottom">
+ android:layout_margin="@dimen/search_bar_margin">
<com.google.android.material.card.MaterialCardView
android:id="@+id/search_bar"
@@ -34,7 +31,7 @@
android:id="@+id/search_action_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/search_bar_height"
- android:layout_marginStart="-2dp"
+ android:paddingStart="4dp"
android:background="@drawable/search_bar_selected_background"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_homepage_search">
@@ -43,16 +40,11 @@
style="@style/TextAppearance.SearchBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:paddingStart="-4dp"
android:layout_gravity="start"
android:text="@string/search_menu"/>
</Toolbar>
</com.google.android.material.card.MaterialCardView>
- <ImageView
- android:id="@+id/account_avatar"
- android:layout_width="@dimen/avatar_length"
- android:layout_height="@dimen/avatar_length"
- android:layout_gravity="center_vertical"
- android:contentDescription="@string/search_bar_account_avatar_content_description"/>
</LinearLayout>
diff --git a/res/layout/settings_homepage_container.xml b/res/layout/settings_homepage_container.xml
index d9bcb83..4fd62fd 100644
--- a/res/layout/settings_homepage_container.xml
+++ b/res/layout/settings_homepage_container.xml
@@ -65,34 +65,26 @@
android:orientation="vertical"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
- <LinearLayout
- android:id="@+id/contextual_suggestion_content"
+ <ImageView
+ android:id="@+id/account_avatar"
+ android:layout_width="@dimen/avatar_length"
+ android:layout_height="@dimen/avatar_length"
+ android:layout_marginTop="@dimen/avatar_margin_top"
+ android:layout_marginEnd="@dimen/avatar_margin_end"
+ android:layout_gravity="end"
+ android:visibility="invisible"
+ android:accessibilityTraversalAfter="@id/homepage_title"
+ android:contentDescription="@string/search_bar_account_avatar_content_description"/>
+
+ <TextView
+ android:id="@+id/homepage_title"
+ android:text="@string/settings_label"
+ style="@style/HomepageTitleText"/>
+
+ <FrameLayout
+ android:id="@+id/suggestion_content"
android:layout_width="match_parent"
- android:layout_height="@dimen/suggestion_height"
- android:paddingHorizontal="@dimen/suggestion_padding_horizontal"
- android:paddingVertical="@dimen/suggestion_padding_vertical"
- android:orientation="vertical"
- android:gravity="bottom"
- android:visibility="gone">
-
- <TextView
- android:id="@+id/suggestion_title"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:text="@string/settings_label"
- style="@style/ContextualSuggestionText"/>
-
- <Button
- android:id="@+id/suggestion_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suggestion_button_margin_top"
- android:paddingHorizontal="@dimen/suggestion_button_padding_horizontal"
- android:visibility="gone"
- style="@style/ActionPrimaryButton"/>
-
- </LinearLayout>
+ android:layout_height="wrap_content"/>
<include layout="@layout/search_bar"/>
diff --git a/res/layout/vpn_dialog.xml b/res/layout/vpn_dialog.xml
index 73f669b..9e264f9 100644
--- a/res/layout/vpn_dialog.xml
+++ b/res/layout/vpn_dialog.xml
@@ -13,218 +13,254 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingTop="0dp"
+ android:paddingLeft="24dp"
+ android:paddingRight="24dp" >
+ <TextView
android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="24dp">
+ android:layout_height="wrap_content"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"
+ android:id="@+id/dialog_alert_subtitle"
+ android:text="@string/vpn_insecure_dialog_subtitle"
+ android:textColor="?android:attr/colorError"
+ android:visibility="gone"
+ android:includeFontPadding="false"
+ android:padding="0dp" />
- <LinearLayout android:id="@+id/editor"
- android:layout_width="match_parent"
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:visibility="gone">
+ android:paddingTop="24dp">
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_name"
- android:labelFor="@+id/name"/>
- <EditText style="@style/vpn_value" android:id="@+id/name"
- android:inputType="textCapWords"/>
-
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_type"
- android:labelFor="@+id/type"/>
- <Spinner style="@style/vpn_value"
- android:id="@+id/type"
- android:prompt="@string/vpn_type"
- android:entries="@array/vpn_types"/>
-
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_server"
- android:labelFor="@+id/server"/>
- <EditText style="@style/vpn_value" android:id="@+id/server"/>
-
- <CheckBox style="@style/vpn_value" android:id="@+id/mppe"
- android:text="@string/vpn_mppe"
- android:singleLine="false"
- android:visibility="gone"/>
-
- <LinearLayout android:id="@+id/l2tp"
+ <LinearLayout android:id="@+id/editor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
+
<TextView style="@style/vpn_label"
- android:text="@string/vpn_l2tp_secret"
- android:labelFor="@+id/l2tp_secret"/>
- <EditText style="@style/vpn_value" android:id="@+id/l2tp_secret"
- android:password="true"
- android:hint="@string/vpn_not_used"/>
+ android:text="@string/vpn_name"
+ android:labelFor="@+id/name"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/name"
+ android:inputType="textCapWords"/>
+
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_type"
+ android:labelFor="@+id/type"/>
+ <Spinner style="@style/vpn_value"
+ android:id="@+id/type"
+ android:prompt="@string/vpn_type"
+ android:entries="@array/vpn_types"/>
+
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_server"
+ android:labelFor="@+id/server"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/server"/>
+
+ <CheckBox style="@style/vpn_value"
+ android:id="@+id/mppe"
+ android:text="@string/vpn_mppe"
+ android:singleLine="false"
+ android:visibility="gone"/>
+
+ <LinearLayout android:id="@+id/l2tp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="gone">
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_l2tp_secret"
+ android:labelFor="@+id/l2tp_secret"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/l2tp_secret"
+ android:password="true"
+ android:hint="@string/vpn_not_used"/>
+ </LinearLayout>
+
+ <LinearLayout android:id="@+id/options_ipsec_identity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="gone">
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_ipsec_identifier"
+ android:labelFor="@+id/ipsec_identifier"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/ipsec_identifier"
+ android:hint="@string/vpn_not_used"/>
+ </LinearLayout>
+
+ <LinearLayout android:id="@+id/ipsec_psk"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="gone">
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_ipsec_secret"
+ android:labelFor="@+id/ipsec_secret"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/ipsec_secret"
+ android:password="true"/>
+ </LinearLayout>
+
+ <LinearLayout android:id="@+id/ipsec_user"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="gone">
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_ipsec_user_cert"
+ android:labelFor="@+id/ipsec_user_cert"/>
+ <Spinner style="@style/vpn_value"
+ android:id="@+id/ipsec_user_cert"
+ android:prompt="@string/vpn_ipsec_user_cert" />
+ </LinearLayout>
+
+ <LinearLayout android:id="@+id/ipsec_peer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="gone">
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_ipsec_ca_cert"
+ android:labelFor="@+id/ipsec_ca_cert"/>
+ <Spinner style="@style/vpn_value"
+ android:id="@+id/ipsec_ca_cert"
+ android:prompt="@string/vpn_ipsec_ca_cert" />
+
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_ipsec_server_cert"
+ android:labelFor="@+id/ipsec_server_cert"/>
+ <Spinner style="@style/vpn_value"
+ android:id="@+id/ipsec_server_cert"
+ android:prompt="@string/vpn_ipsec_server_cert" />
+ </LinearLayout>
+
+ <CheckBox style="@style/vpn_value"
+ android:id="@+id/show_options"
+ android:singleLine="false"
+ android:text="@string/vpn_show_options"/>
</LinearLayout>
- <LinearLayout android:id="@+id/options_ipsec_identity"
+ <LinearLayout android:id="@+id/options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_ipsec_identifier"
- android:labelFor="@+id/ipsec_identifier"/>
- <EditText style="@style/vpn_value" android:id="@+id/ipsec_identifier"
- android:hint="@string/vpn_not_used"/>
+ <LinearLayout android:id="@+id/network_options"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_search_domains"
+ android:labelFor="@+id/search_domains"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/search_domains"
+ android:hint="@string/vpn_not_used"/>
+
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_dns_servers"
+ android:labelFor="@+id/dns_servers"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/dns_servers"
+ android:hint="@string/vpn_not_used"/>
+
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_routes"
+ android:labelFor="@+id/routes"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/routes"
+ android:hint="@string/vpn_not_used"/>
+ </LinearLayout>
+
+ <TextView android:id="@+id/vpn_proxy_settings_title"
+ style="@style/vpn_label"
+ android:text="@string/proxy_settings_title"
+ android:labelFor="@+id/vpn_proxy_settings" />
+
+ <Spinner android:id="@+id/vpn_proxy_settings"
+ style="@style/vpn_value"
+ android:prompt="@string/proxy_settings_title"
+ android:entries="@array/vpn_proxy_settings" />
+
+ <LinearLayout
+ android:id="@+id/vpn_proxy_fields"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="gone" >
+
+ <TextView
+ style="@style/vpn_label"
+ android:text="@string/proxy_hostname_label"
+ android:labelFor="@+id/vpn_proxy_host" />
+
+ <EditText
+ android:id="@+id/vpn_proxy_host"
+ style="@style/vpn_value"
+ android:hint="@string/proxy_hostname_hint"
+ android:inputType="textNoSuggestions" />
+
+ <TextView
+ style="@style/vpn_label"
+ android:text="@string/proxy_port_label"
+ android:labelFor="@+id/vpn_proxy_port" />
+
+ <EditText
+ android:id="@+id/vpn_proxy_port"
+ style="@style/vpn_value"
+ android:hint="@string/proxy_port_hint"
+ android:inputType="number" />
+ </LinearLayout>
</LinearLayout>
- <LinearLayout android:id="@+id/ipsec_psk"
+ <LinearLayout android:id="@+id/userpass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:visibility="gone">
+ android:orientation="vertical">
+
<TextView style="@style/vpn_label"
- android:text="@string/vpn_ipsec_secret"
- android:labelFor="@+id/ipsec_secret"/>
- <EditText style="@style/vpn_value" android:id="@+id/ipsec_secret"
+ android:text="@string/vpn_username"
+ android:labelFor="@+id/username"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/username"/>
+
+ <TextView style="@style/vpn_label"
+ android:text="@string/vpn_password"
+ android:labelFor="@+id/password"/>
+ <EditText style="@style/vpn_value"
+ android:id="@+id/password"
android:password="true"/>
+
+ <CheckBox style="@style/vpn_value"
+ android:id="@+id/save_login"
+ android:singleLine="false"
+ android:text="@string/vpn_save_login"/>
</LinearLayout>
- <LinearLayout android:id="@+id/ipsec_user"
+ <LinearLayout android:id="@+id/connect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:visibility="gone">
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_ipsec_user_cert"
- android:labelFor="@+id/ipsec_user_cert"/>
- <Spinner style="@style/vpn_value" android:id="@+id/ipsec_user_cert"
- android:prompt="@string/vpn_ipsec_user_cert" />
- </LinearLayout>
-
- <LinearLayout android:id="@+id/ipsec_peer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:visibility="gone">
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_ipsec_ca_cert"
- android:labelFor="@+id/ipsec_ca_cert"/>
- <Spinner style="@style/vpn_value" android:id="@+id/ipsec_ca_cert"
- android:prompt="@string/vpn_ipsec_ca_cert" />
-
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_ipsec_server_cert"
- android:labelFor="@+id/ipsec_server_cert"/>
- <Spinner style="@style/vpn_value" android:id="@+id/ipsec_server_cert"
- android:prompt="@string/vpn_ipsec_server_cert" />
- </LinearLayout>
-
- <CheckBox style="@style/vpn_value" android:id="@+id/show_options"
- android:singleLine="false"
- android:text="@string/vpn_show_options"/>
- </LinearLayout>
-
- <LinearLayout android:id="@+id/options"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:visibility="gone">
- <LinearLayout android:id="@+id/network_options"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_search_domains"
- android:labelFor="@+id/search_domains"/>
- <EditText style="@style/vpn_value" android:id="@+id/search_domains"
- android:hint="@string/vpn_not_used"/>
-
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_dns_servers"
- android:labelFor="@+id/dns_servers"/>
- <EditText style="@style/vpn_value" android:id="@+id/dns_servers"
- android:hint="@string/vpn_not_used"/>
-
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_routes"
- android:labelFor="@+id/routes"/>
- <EditText style="@style/vpn_value" android:id="@+id/routes"
- android:hint="@string/vpn_not_used"/>
- </LinearLayout>
-
- <TextView android:id="@+id/vpn_proxy_settings_title"
- style="@style/vpn_label"
- android:text="@string/proxy_settings_title"
- android:labelFor="@+id/vpn_proxy_settings" />
-
- <Spinner android:id="@+id/vpn_proxy_settings"
- style="@style/vpn_value"
- android:prompt="@string/proxy_settings_title"
- android:entries="@array/vpn_proxy_settings" />
-
- <LinearLayout
- android:id="@+id/vpn_proxy_fields"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:visibility="gone" >
-
- <TextView
- style="@style/vpn_label"
- android:text="@string/proxy_hostname_label"
- android:labelFor="@+id/vpn_proxy_host" />
-
- <EditText
- android:id="@+id/vpn_proxy_host"
- style="@style/vpn_value"
- android:hint="@string/proxy_hostname_hint"
- android:inputType="textNoSuggestions" />
-
- <TextView
- style="@style/vpn_label"
- android:text="@string/proxy_port_label"
- android:labelFor="@+id/vpn_proxy_port" />
-
- <EditText
- android:id="@+id/vpn_proxy_port"
- style="@style/vpn_value"
- android:hint="@string/proxy_port_hint"
- android:inputType="number" />
+ android:animateLayoutChanges="true">
+ <CheckBox style="@style/vpn_value"
+ android:id="@+id/always_on_vpn"
+ android:singleLine="false"
+ android:text="@string/vpn_menu_lockdown"/>
+ <TextView style="@style/vpn_warning"
+ android:id="@+id/always_on_invalid_reason"
+ android:singleLine="false"
+ android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
-
- <LinearLayout android:id="@+id/userpass"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_username"
- android:labelFor="@+id/username"/>
- <EditText style="@style/vpn_value" android:id="@+id/username"/>
-
- <TextView style="@style/vpn_label"
- android:text="@string/vpn_password"
- android:labelFor="@+id/password"/>
- <EditText style="@style/vpn_value" android:id="@+id/password"
- android:password="true"/>
-
- <CheckBox style="@style/vpn_value" android:id="@+id/save_login"
- android:singleLine="false"
- android:text="@string/vpn_save_login"/>
- </LinearLayout>
-
- <LinearLayout android:id="@+id/connect"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:animateLayoutChanges="true">
- <CheckBox style="@style/vpn_value" android:id="@+id/always_on_vpn"
- android:singleLine="false"
- android:text="@string/vpn_menu_lockdown"/>
- <TextView style="@style/vpn_warning" android:id="@+id/always_on_invalid_reason"
- android:singleLine="false"
- android:visibility="gone"/>
- </LinearLayout>
- </LinearLayout>
-</ScrollView>
+ </ScrollView>
+</LinearLayout>
diff --git a/res/menu/storage_volume.xml b/res/menu/storage_volume.xml
index bf9f985..87f7515 100644
--- a/res/menu/storage_volume.xml
+++ b/res/menu/storage_volume.xml
@@ -28,9 +28,21 @@
android:id="@+id/storage_format"
android:title="@string/storage_menu_format" />
<item
+ android:id="@+id/storage_format_as_portable"
+ android:title="@string/storage_menu_format_public"
+ android:visible="false" />
+ <item
+ android:id="@+id/storage_format_as_internal"
+ android:title="@string/storage_menu_format_private"
+ android:visible="false" />
+ <item
android:id="@+id/storage_migrate"
android:title="@string/storage_menu_migrate" />
<item
android:id="@+id/storage_free"
android:title="@string/storage_menu_free" />
+ <item
+ android:id="@+id/storage_forget"
+ android:title="@string/storage_menu_forget"
+ android:visible="false" />
</menu>
diff --git a/res/values-af/arrays.xml b/res/values-af/arrays.xml
index b2d5ff1..53e1730 100644
--- a/res/values-af/arrays.xml
+++ b/res/values-af/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Geel op blou"</item>
<item msgid="747238414788976867">"Gepasmaak"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Sweef oor ander programme"</item>
+ <item msgid="3605616699204153590">"Navigasiebalk"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Klein"</item>
+ <item msgid="1666628329913333563">"Groot"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN met voorafgedeelde sleutels"</item>
diff --git a/res/values-am/arrays.xml b/res/values-am/arrays.xml
index b51723b..8e67eff 100644
--- a/res/values-am/arrays.xml
+++ b/res/values-am/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"ቢጫ በሰማያዊ ላይ"</item>
<item msgid="747238414788976867">"ብጁ"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"በሌሎች መተግበሪያዎች ላይ በመንሳፈፍ ላይበሪያዎች ላይ መቀያየር"</item>
+ <item msgid="3605616699204153590">"የአሰሳ አሞሌ"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"ትንሽ"</item>
+ <item msgid="1666628329913333563">"ትልቅ"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN ከቅድመ-ተጋሪ ቁልፎች ጋር"</item>
diff --git a/res/values-ar/arrays.xml b/res/values-ar/arrays.xml
index e5082bf..d802340 100644
--- a/res/values-ar/arrays.xml
+++ b/res/values-ar/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"أصفر في أزرق"</item>
<item msgid="747238414788976867">"مخصص"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"عائم فوق التطبيقات الأخرى"</item>
+ <item msgid="3605616699204153590">"شريط التنقل"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"صغير"</item>
+ <item msgid="1666628329913333563">"كبير"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"شبكة افتراضية خاصة (VPN) عبر PPTP"</item>
<item msgid="2552427673212085780">"شبكة افتراضية خاصة (VPN) لـ L2TP/IPSec مزودة بمفاتيح مشتركة مسبقًا"</item>
diff --git a/res/values-as/arrays.xml b/res/values-as/arrays.xml
index ff25aa7..c9cc034 100644
--- a/res/values-as/arrays.xml
+++ b/res/values-as/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"নীলাৰ ওপৰত হালধীয়া"</item>
<item msgid="747238414788976867">"নিজৰ উপযোগিতা অনুযায়ী তৈয়াৰ কৰা"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"অন্য এপৰ ওপৰত ওপঙি আছে"</item>
+ <item msgid="3605616699204153590">"নেভিগেশ্বন বাৰ"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"সৰু"</item>
+ <item msgid="1666628329913333563">"ডাঙৰ"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"পিপিটিপি ভিপিএন"</item>
<item msgid="2552427673212085780">"পূৰ্বে ভাগ-বতৰা কৰা কীসমূহৰ সৈতে L2TP/IPSec ভিপিএন"</item>
diff --git a/res/values-az/arrays.xml b/res/values-az/arrays.xml
index 2f6a67a..41c78a6 100644
--- a/res/values-az/arrays.xml
+++ b/res/values-az/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Mavi üstündə sarı"</item>
<item msgid="747238414788976867">"Fərd"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Digər tətbiqlərin üzərində üzür"</item>
+ <item msgid="3605616699204153590">"Naviqasiya paneli"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Kiçik"</item>
+ <item msgid="1666628329913333563">"Böyük"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"Öncədən paylaşılmış açarlar ilə L2TP/IPSec VPN"</item>
diff --git a/res/values-b+sr+Latn/arrays.xml b/res/values-b+sr+Latn/arrays.xml
index 8b6de00..52c60b6 100644
--- a/res/values-b+sr+Latn/arrays.xml
+++ b/res/values-b+sr+Latn/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Žuto na plavo"</item>
<item msgid="747238414788976867">"Prilagođeno"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Pluta preko drugih aplikacija"</item>
+ <item msgid="3605616699204153590">"Traka za navigaciju"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Mala"</item>
+ <item msgid="1666628329913333563">"Velika"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN sa unapred deljenim ključevima"</item>
diff --git a/res/values-be/arrays.xml b/res/values-be/arrays.xml
index 090b0f7..e96e881 100644
--- a/res/values-be/arrays.xml
+++ b/res/values-be/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Жоўты на сінім"</item>
<item msgid="747238414788976867">"Карыстальніцкі"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Плаваючая кнопка паверх праграм"</item>
+ <item msgid="3605616699204153590">"Панэль навігацыі"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Маленькая"</item>
+ <item msgid="1666628329913333563">"Вялікая"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN з загадзя размеркаванымі ключамі"</item>
diff --git a/res/values-bg/arrays.xml b/res/values-bg/arrays.xml
index baf8536..7ab3d37 100644
--- a/res/values-bg/arrays.xml
+++ b/res/values-bg/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Жълто върху синьо"</item>
<item msgid="747238414788976867">"Персонализиран"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Плаващ елемент над други приложения"</item>
+ <item msgid="3605616699204153590">"Лента за навигация"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Малък"</item>
+ <item msgid="1666628329913333563">"Голям"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN с PPTP"</item>
<item msgid="2552427673212085780">"VPN с L2TP/IPSec с предварително споделени ключове"</item>
diff --git a/res/values-bn/arrays.xml b/res/values-bn/arrays.xml
index 7a0afc9..b97e0b5 100644
--- a/res/values-bn/arrays.xml
+++ b/res/values-bn/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"নীলের উপর হলুদ"</item>
<item msgid="747238414788976867">"কাস্টম"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"মাল্টিটাস্কিং করতে অন্যান্য অ্যাপের উপরে ভেসে থাকা"</item>
+ <item msgid="3605616699204153590">"নেভিগেশন বার"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"ছোট"</item>
+ <item msgid="1666628329913333563">"বড়"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"আগে থেকে শেয়ার করা কীগুলির সাথে L2TP/IPSec VPN"</item>
diff --git a/res/values-bs/arrays.xml b/res/values-bs/arrays.xml
index 2c095f5..0ce7093 100644
--- a/res/values-bs/arrays.xml
+++ b/res/values-bs/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Žuto na plavom"</item>
<item msgid="747238414788976867">"Prilagođeno"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Plutanje preko drugih aplikacija"</item>
+ <item msgid="3605616699204153590">"Navigaciona traka"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Malo"</item>
+ <item msgid="1666628329913333563">"Veliko"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN sa pre-shared lozinkama"</item>
diff --git a/res/values-ca/arrays.xml b/res/values-ca/arrays.xml
index b73e650..9f062ca 100644
--- a/res/values-ca/arrays.xml
+++ b/res/values-ca/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Groc sobre blau"</item>
<item msgid="747238414788976867">"Personalitzat"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flotant sobre altres aplicacions"</item>
+ <item msgid="3605616699204153590">"Barra de navegació"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Petit"</item>
+ <item msgid="1666628329913333563">"Gran"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"VPN L2TP/IPSec amb claus prèviament compartides"</item>
diff --git a/res/values-cs/arrays.xml b/res/values-cs/arrays.xml
index 0a8a790..625f457 100644
--- a/res/values-cs/arrays.xml
+++ b/res/values-cs/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Žluté na modrém"</item>
<item msgid="747238414788976867">"Vlastní"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Plovoucí přes ostatní aplikace"</item>
+ <item msgid="3605616699204153590">"Navigační panel"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Malé"</item>
+ <item msgid="1666628329913333563">"Velké"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN s protokolem PPTP"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN s předsdílenými klíči"</item>
diff --git a/res/values-da/arrays.xml b/res/values-da/arrays.xml
index 7d7b686..6cac514 100644
--- a/res/values-da/arrays.xml
+++ b/res/values-da/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Gult på blåt"</item>
<item msgid="747238414788976867">"Tilpasset"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Vises over andre apps"</item>
+ <item msgid="3605616699204153590">"Navigationslinje"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Lille"</item>
+ <item msgid="1666628329913333563">"Stor"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP-VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPsec VPN med forhåndsdelte nøgler"</item>
diff --git a/res/values-de/arrays.xml b/res/values-de/arrays.xml
index 18358ac..aeaee4a 100644
--- a/res/values-de/arrays.xml
+++ b/res/values-de/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Gelb auf Blau"</item>
<item msgid="747238414788976867">"Personalisiert"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Unverankert über anderen Apps"</item>
+ <item msgid="3605616699204153590">"Navigationsleiste"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Klein"</item>
+ <item msgid="1666628329913333563">"Groß"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP-VPN"</item>
<item msgid="2552427673212085780">"L2TP-/IPSec-VPN mit vorinstallierten Schlüsseln"</item>
diff --git a/res/values-el/arrays.xml b/res/values-el/arrays.xml
index d5f9fab..6532ab6 100644
--- a/res/values-el/arrays.xml
+++ b/res/values-el/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Κίτρινο σε μπλε"</item>
<item msgid="747238414788976867">"Προσαρμογή"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Κινούμενο πάνω από άλλες εφαρμογές"</item>
+ <item msgid="3605616699204153590">"Γραμμή πλοήγησης"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Μικρό"</item>
+ <item msgid="1666628329913333563">"Μεγάλο"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN με κλειδιά μοιρασμένα εκ των προτέρων"</item>
diff --git a/res/values-en-rAU/arrays.xml b/res/values-en-rAU/arrays.xml
index abf2d74..196868c 100644
--- a/res/values-en-rAU/arrays.xml
+++ b/res/values-en-rAU/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Yellow on blue"</item>
<item msgid="747238414788976867">"Customise"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Floating over other apps"</item>
+ <item msgid="3605616699204153590">"Navigation bar"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Small"</item>
+ <item msgid="1666628329913333563">"Large"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN with preshared keys"</item>
diff --git a/res/values-en-rCA/arrays.xml b/res/values-en-rCA/arrays.xml
index 54395da..015530f 100644
--- a/res/values-en-rCA/arrays.xml
+++ b/res/values-en-rCA/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Yellow on blue"</item>
<item msgid="747238414788976867">"Customise"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Floating over other apps"</item>
+ <item msgid="3605616699204153590">"Navigation bar"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Small"</item>
+ <item msgid="1666628329913333563">"Large"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN with preshared keys"</item>
diff --git a/res/values-en-rGB/arrays.xml b/res/values-en-rGB/arrays.xml
index abf2d74..196868c 100644
--- a/res/values-en-rGB/arrays.xml
+++ b/res/values-en-rGB/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Yellow on blue"</item>
<item msgid="747238414788976867">"Customise"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Floating over other apps"</item>
+ <item msgid="3605616699204153590">"Navigation bar"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Small"</item>
+ <item msgid="1666628329913333563">"Large"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN with preshared keys"</item>
diff --git a/res/values-en-rIN/arrays.xml b/res/values-en-rIN/arrays.xml
index abf2d74..196868c 100644
--- a/res/values-en-rIN/arrays.xml
+++ b/res/values-en-rIN/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Yellow on blue"</item>
<item msgid="747238414788976867">"Customise"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Floating over other apps"</item>
+ <item msgid="3605616699204153590">"Navigation bar"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Small"</item>
+ <item msgid="1666628329913333563">"Large"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN with preshared keys"</item>
diff --git a/res/values-en-rXC/arrays.xml b/res/values-en-rXC/arrays.xml
index 0144775..a5a9a76 100644
--- a/res/values-en-rXC/arrays.xml
+++ b/res/values-en-rXC/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Yellow on blue"</item>
<item msgid="747238414788976867">"Custom"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Floating over other apps"</item>
+ <item msgid="3605616699204153590">"Navigation bar"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Small"</item>
+ <item msgid="1666628329913333563">"Large"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN with pre-shared keys"</item>
diff --git a/res/values-es-rUS/arrays.xml b/res/values-es-rUS/arrays.xml
index af9cd1e..37f174e 100644
--- a/res/values-es-rUS/arrays.xml
+++ b/res/values-es-rUS/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Amarillo sobre azul"</item>
<item msgid="747238414788976867">"Personalizado"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flotando encima de otras apps"</item>
+ <item msgid="3605616699204153590">"Barra de navegación"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Pequeño"</item>
+ <item msgid="1666628329913333563">"Grande"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"Claves precompartidas de VPN L2TP/IPSec"</item>
diff --git a/res/values-es/arrays.xml b/res/values-es/arrays.xml
index 650379f..6c757bb 100644
--- a/res/values-es/arrays.xml
+++ b/res/values-es/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Amarillo sobre azul"</item>
<item msgid="747238414788976867">"Personalizado"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Se muestra sobre otras aplicaciones"</item>
+ <item msgid="3605616699204153590">"Barra de navegación"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Pequeño"</item>
+ <item msgid="1666628329913333563">"Grande"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"Red privada virtual PPTP"</item>
<item msgid="2552427673212085780">"Red privada virtual L2TP/IPSec con claves precompartidas"</item>
diff --git a/res/values-et/arrays.xml b/res/values-et/arrays.xml
index c10f340..e5d08c9 100644
--- a/res/values-et/arrays.xml
+++ b/res/values-et/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Kollane sinisel"</item>
<item msgid="747238414788976867">"Kohandatud"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Hõljub teiste rakenduste kohal"</item>
+ <item msgid="3605616699204153590">"Navigeerimisriba"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Väike"</item>
+ <item msgid="1666628329913333563">"Suur"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN eeljagatud võtmetega"</item>
diff --git a/res/values-eu/arrays.xml b/res/values-eu/arrays.xml
index 3a4694b..e558843 100644
--- a/res/values-eu/arrays.xml
+++ b/res/values-eu/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Horia urdinaren gainean"</item>
<item msgid="747238414788976867">"Pertsonalizatua"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Beste aplikazio batzuen gainean"</item>
+ <item msgid="3605616699204153590">"Nabigazio-barra"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Txikia"</item>
+ <item msgid="1666628329913333563">"Handia"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPNa aurrez partekatutako gakoekin"</item>
diff --git a/res/values-fa/arrays.xml b/res/values-fa/arrays.xml
index 186afff..fabe268 100644
--- a/res/values-fa/arrays.xml
+++ b/res/values-fa/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"زرد در آبی"</item>
<item msgid="747238414788976867">"سفارشی"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"شناور روی برنامههای دیگر"</item>
+ <item msgid="3605616699204153590">"نوار پیمایش"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"کوچک"</item>
+ <item msgid="1666628329913333563">"بزرگ"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN با کلیدهای از قبل به اشتراک گذاشته شده"</item>
diff --git a/res/values-fi/arrays.xml b/res/values-fi/arrays.xml
index bdf4085..cedbcaf 100644
--- a/res/values-fi/arrays.xml
+++ b/res/values-fi/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Keltainen sinisellä"</item>
<item msgid="747238414788976867">"Muokattu"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Kelluu muiden sovellusten päällä"</item>
+ <item msgid="3605616699204153590">"Siirtymispalkki"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Pieni"</item>
+ <item msgid="1666628329913333563">"Suuri"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"Esijaettuun avaimeen perustuva L2TP-/IPSec-VPN-verkko"</item>
diff --git a/res/values-fr-rCA/arrays.xml b/res/values-fr-rCA/arrays.xml
index daf452c..0035d24 100644
--- a/res/values-fr-rCA/arrays.xml
+++ b/res/values-fr-rCA/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Texte jaune sur fond bleu"</item>
<item msgid="747238414788976867">"Personnalisé"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flottant par-dessus d\'autres applis"</item>
+ <item msgid="3605616699204153590">"Barre de navigation"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Petite"</item>
+ <item msgid="1666628329913333563">"Grande"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"RPV PPTP"</item>
<item msgid="2552427673212085780">"RPV L2TP/IPSec avec clés pré-partagées"</item>
diff --git a/res/values-fr/arrays.xml b/res/values-fr/arrays.xml
index c5f3c4a..39954d0 100644
--- a/res/values-fr/arrays.xml
+++ b/res/values-fr/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Texte jaune sur fond bleu"</item>
<item msgid="747238414788976867">"Personnalisé"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flottant sur les autres applis"</item>
+ <item msgid="3605616699204153590">"Barre de navigation"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Petit"</item>
+ <item msgid="1666628329913333563">"Grand"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"VPN L2TP/IPSec avec clés pré-partagées"</item>
diff --git a/res/values-gl/arrays.xml b/res/values-gl/arrays.xml
index 8de9e56..e688500 100644
--- a/res/values-gl/arrays.xml
+++ b/res/values-gl/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Amarelo sobre azul"</item>
<item msgid="747238414788976867">"Personalizado"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flotando sobre outras aplicacións"</item>
+ <item msgid="3605616699204153590">"Barra de navegación"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Pequeno"</item>
+ <item msgid="1666628329913333563">"Grande"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"VPN L2TP/IPSec con claves precompartidas"</item>
diff --git a/res/values-gu/arrays.xml b/res/values-gu/arrays.xml
index e4d4264..555707c 100644
--- a/res/values-gu/arrays.xml
+++ b/res/values-gu/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"વાદળી પર પીળી"</item>
<item msgid="747238414788976867">"કસ્ટમ"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"અન્ય ઍપની ઉપર ફ્લોટિંગ"</item>
+ <item msgid="3605616699204153590">"નૅવિગેશન બાર"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"નાનું"</item>
+ <item msgid="1666628329913333563">"મોટું"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"પહેલાંથી શેર કરેલ કીઝ સાથે L2TP/IPSec VPN"</item>
diff --git a/res/values-hi/arrays.xml b/res/values-hi/arrays.xml
index c719208..d7cf7a2 100644
--- a/res/values-hi/arrays.xml
+++ b/res/values-hi/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"नीले पर पीला"</item>
<item msgid="747238414788976867">"पसंद के मुताबिक"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"दूसरे ऐप्लिकेशन के ऊपर फ़्लोट कर रहा है"</item>
+ <item msgid="3605616699204153590">"नेविगेशन बार"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"छोटा"</item>
+ <item msgid="1666628329913333563">"बड़ा"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"पहले से शेयर की गई कुंजी के साथ L2TP/IPSec VPN"</item>
diff --git a/res/values-hr/arrays.xml b/res/values-hr/arrays.xml
index 15583bf..a792e90 100644
--- a/res/values-hr/arrays.xml
+++ b/res/values-hr/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Žuto na plavom"</item>
<item msgid="747238414788976867">"Prilagođeno"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Plutanje preko drugih aplikacija"</item>
+ <item msgid="3605616699204153590">"Navigacijska traka"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Malen"</item>
+ <item msgid="1666628329913333563">"Velik"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN s unaprijed dijeljenim ključevima"</item>
diff --git a/res/values-hu/arrays.xml b/res/values-hu/arrays.xml
index 41ba9d5..a253054 100644
--- a/res/values-hu/arrays.xml
+++ b/res/values-hu/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Kék alapon sárga"</item>
<item msgid="747238414788976867">"Egyedi"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Lebegés más alkalmazások fölött"</item>
+ <item msgid="3605616699204153590">"Navigációs sáv"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Kicsi"</item>
+ <item msgid="1666628329913333563">"Nagy"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN megosztott kulcsokkal"</item>
diff --git a/res/values-hy/arrays.xml b/res/values-hy/arrays.xml
index 605f265..a39b732 100644
--- a/res/values-hy/arrays.xml
+++ b/res/values-hy/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Դեղինը կապույտի վրա"</item>
<item msgid="747238414788976867">"Հատուկ"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Ցուցադրվում է այլ հավելվածների վրայից"</item>
+ <item msgid="3605616699204153590">"Նավիգացիայի գոտի"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Փոքր"</item>
+ <item msgid="1666628329913333563">"Մեծ"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN նախորոշված ստեղներով"</item>
diff --git a/res/values-in/arrays.xml b/res/values-in/arrays.xml
index f2a40a7..c46d3c8 100644
--- a/res/values-in/arrays.xml
+++ b/res/values-in/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Kuning berlatar biru"</item>
<item msgid="747238414788976867">"Khusus"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Mengambang di atas aplikasi lain"</item>
+ <item msgid="3605616699204153590">"Menu navigasi"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Kecil"</item>
+ <item msgid="1666628329913333563">"Besar"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN dengan kunci pra-bagi"</item>
diff --git a/res/values-is/arrays.xml b/res/values-is/arrays.xml
index b67be26..b8739ca 100644
--- a/res/values-is/arrays.xml
+++ b/res/values-is/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Gult á bláu"</item>
<item msgid="747238414788976867">"Sérsniðið"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Fljótandi yfir öðrum forritum"</item>
+ <item msgid="3605616699204153590">"Yfirlitsstika"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Lítill"</item>
+ <item msgid="1666628329913333563">"Stór"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN með lyklum sem hefur verið deilt"</item>
diff --git a/res/values-it/arrays.xml b/res/values-it/arrays.xml
index a4c0443..717a4da 100644
--- a/res/values-it/arrays.xml
+++ b/res/values-it/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Giallo su blu"</item>
<item msgid="747238414788976867">"Personalizzato"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Mobile sopra altre app"</item>
+ <item msgid="3605616699204153590">"Barra di navigazione"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Piccolo"</item>
+ <item msgid="1666628329913333563">"Grande"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"VPN L2TP/IPSec con chiavi precondivise"</item>
diff --git a/res/values-iw/arrays.xml b/res/values-iw/arrays.xml
index cfa1350..7ba72f5 100644
--- a/res/values-iw/arrays.xml
+++ b/res/values-iw/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"צהוב על גבי כחול"</item>
<item msgid="747238414788976867">"מותאם אישית"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"צף מעל אפליקציות אחרות"</item>
+ <item msgid="3605616699204153590">"סרגל ניווט"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"קטן"</item>
+ <item msgid="1666628329913333563">"גדול"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN עם מפתחות משותפים מראש"</item>
diff --git a/res/values-ja/arrays.xml b/res/values-ja/arrays.xml
index 6a4e186..4431a17 100644
--- a/res/values-ja/arrays.xml
+++ b/res/values-ja/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"青地に黄色"</item>
<item msgid="747238414788976867">"カスタム"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"他のアプリの上にフローティング"</item>
+ <item msgid="3605616699204153590">"ナビゲーション バー"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"小"</item>
+ <item msgid="1666628329913333563">"大"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"事前共有鍵付きのL2TP/IPSec VPN"</item>
diff --git a/res/values-ka/arrays.xml b/res/values-ka/arrays.xml
index d6c826e..8e0e04f 100644
--- a/res/values-ka/arrays.xml
+++ b/res/values-ka/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"ყვითელი ლურჯზე"</item>
<item msgid="747238414788976867">"მორგებული"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"გადაფარვითი ჩვენება სხვა აპებზე ლივლივით"</item>
+ <item msgid="3605616699204153590">"ნავიგაციის ზოლი"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"პატარა"</item>
+ <item msgid="1666628329913333563">"დიდი"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN წინასწარ გაზიარებული ღილაკებით"</item>
diff --git a/res/values-kk/arrays.xml b/res/values-kk/arrays.xml
index b499a8e..58922a3 100644
--- a/res/values-kk/arrays.xml
+++ b/res/values-kk/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Көк түсте сарымен"</item>
<item msgid="747238414788976867">"Басқа"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Басқа қолданбалар үстінен қалқу"</item>
+ <item msgid="3605616699204153590">"Навигация жолағы"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Кішкентай"</item>
+ <item msgid="1666628329913333563">"Үлкен"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec, пернелері ортақ ВЖЖ"</item>
diff --git a/res/values-km/arrays.xml b/res/values-km/arrays.xml
index 052f638..9e7f634 100644
--- a/res/values-km/arrays.xml
+++ b/res/values-km/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"ពណ៌លឿងលើពណ៌ខៀវ"</item>
<item msgid="747238414788976867">"តាមបំណង"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"កំពុងអណ្ដែតពីលើកម្មវិធីផ្សេងទៀត"</item>
+ <item msgid="3605616699204153590">"របាររុករក"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"តូច"</item>
+ <item msgid="1666628329913333563">"ធំ"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN ជាមួយសោចែករំលែកជាមុន"</item>
diff --git a/res/values-kn/arrays.xml b/res/values-kn/arrays.xml
index 4ee2b13..eeca4c9 100644
--- a/res/values-kn/arrays.xml
+++ b/res/values-kn/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"ನೀಲಿ ಬಣ್ಣದಲ್ಲಿ ಹಳದಿ"</item>
<item msgid="747238414788976867">"ಕಸ್ಟಮ್"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"ಇತರೆ ಆ್ಯಪ್ಗಳಲ್ಲೂ ರನ್ ಆಗುತ್ತಿದೆ"</item>
+ <item msgid="3605616699204153590">"ನ್ಯಾವಿಗೇಷನ್ ಬಾರ್"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"ಸಣ್ಣದು"</item>
+ <item msgid="1666628329913333563">"ದೊಡ್ಡದು"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"ಪೂರ್ವ-ಹಂಚಿಕೆಯಾದ ಕೀಗಳನ್ನು ಹೊಂದಿರುವ L2TP/IPSec VPN"</item>
diff --git a/res/values-ko/arrays.xml b/res/values-ko/arrays.xml
index e574fa5..a806d87 100644
--- a/res/values-ko/arrays.xml
+++ b/res/values-ko/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"파란색 바탕에 노란색"</item>
<item msgid="747238414788976867">"맞춤설정"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"다른 앱 위에 플로팅"</item>
+ <item msgid="3605616699204153590">"탐색 메뉴"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"작게"</item>
+ <item msgid="1666628329913333563">"크게"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"사전 공유 키를 사용하는 L2TP/IPSec VPN"</item>
diff --git a/res/values-ky/arrays.xml b/res/values-ky/arrays.xml
index 9e70efd..dab63c2 100644
--- a/res/values-ky/arrays.xml
+++ b/res/values-ky/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Сары көктө"</item>
<item msgid="747238414788976867">"Өзгөчөлөнгөн"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Башка колдонмолордун үстүнөн көрсөтүү"</item>
+ <item msgid="3605616699204153590">"Чабыттоо тилкеси"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Кичине"</item>
+ <item msgid="1666628329913333563">"Чоң"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"Алдын ала бөлүшүлгөн ачкычтары бар L2TP/IPSec VPN"</item>
diff --git a/res/values-lo/arrays.xml b/res/values-lo/arrays.xml
index cc5f45b..47906e0 100644
--- a/res/values-lo/arrays.xml
+++ b/res/values-lo/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"ສີເຫຼືອງພື້ນຟ້າ"</item>
<item msgid="747238414788976867">"ກຳນົດເອງ"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"ລອຍຢູ່ເທິງແອັບອື່ນ"</item>
+ <item msgid="3605616699204153590">"ແຖບການນຳທາງ"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"ນ້ອຍ"</item>
+ <item msgid="1666628329913333563">"ໃຫຍ່"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN ທີ່ມີກະແຈທີ່ແບ່ງປັນລ່ວງໜ້າ"</item>
diff --git a/res/values-lt/arrays.xml b/res/values-lt/arrays.xml
index c04c608..a2351d1 100644
--- a/res/values-lt/arrays.xml
+++ b/res/values-lt/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Geltonas ant mėlyno"</item>
<item msgid="747238414788976867">"Tinkintas"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Rodomas virš kitų programų"</item>
+ <item msgid="3605616699204153590">"Naršymo juosta"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Mažas"</item>
+ <item msgid="1666628329913333563">"Didelis"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP / „IPSec“ VPN su iš anksto bendrinamais raktais"</item>
diff --git a/res/values-lv/arrays.xml b/res/values-lv/arrays.xml
index 54e659a..5bd48d0 100644
--- a/res/values-lv/arrays.xml
+++ b/res/values-lv/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Dzeltens uz zila"</item>
<item msgid="747238414788976867">"Pielāgots"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Peldoša poga virs lietotnēm"</item>
+ <item msgid="3605616699204153590">"Navigācijas joslā"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Maza"</item>
+ <item msgid="1666628329913333563">"Liela"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"Otrā slāņa tunelēšanas protokola/protokola IPsec VPN ar iepriekš kopīgotām atslēgām"</item>
diff --git a/res/values-mk/arrays.xml b/res/values-mk/arrays.xml
index 16e12e4..d3f382c 100644
--- a/res/values-mk/arrays.xml
+++ b/res/values-mk/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Жолти на сино"</item>
<item msgid="747238414788976867">"Приспособено"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Лебди над други апликации"</item>
+ <item msgid="3605616699204153590">"Лента за навигација"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Мало"</item>
+ <item msgid="1666628329913333563">"Големо"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN со претходно споделени клучеви"</item>
diff --git a/res/values-ml/arrays.xml b/res/values-ml/arrays.xml
index 0553306..cd8edbc 100644
--- a/res/values-ml/arrays.xml
+++ b/res/values-ml/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"നീലയിൽ മഞ്ഞ"</item>
<item msgid="747238414788976867">"ഇഷ്ടാനുസൃതം"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"മറ്റ് ആപ്പുകൾക്ക് മുകളിലൂടെ നീങ്ങുന്നു"</item>
+ <item msgid="3605616699204153590">"നാവിഗേഷൻ ബാർ"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"ചെറുത്"</item>
+ <item msgid="1666628329913333563">"വലുത്"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"മുമ്പ് പങ്കിട്ട കീകൾ ഉപയോഗിക്കുന്ന L2TP/IPSec VPN"</item>
diff --git a/res/values-mn/arrays.xml b/res/values-mn/arrays.xml
index 0430de7..ddc8d40 100644
--- a/res/values-mn/arrays.xml
+++ b/res/values-mn/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Цэнхэр дээр шар"</item>
<item msgid="747238414788976867">"Өөрчлөх"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Бусад апп дээр хөвөх"</item>
+ <item msgid="3605616699204153590">"Навигацын самбар"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Жижиг"</item>
+ <item msgid="1666628329913333563">"Том"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"Урьдчилан хуваалцсан L2TP/IPSec VPN түлхүүртэй"</item>
diff --git a/res/values-mr/arrays.xml b/res/values-mr/arrays.xml
index 7f7abb4..60dc05a 100644
--- a/res/values-mr/arrays.xml
+++ b/res/values-mr/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"निळ्यावर पिवळे"</item>
<item msgid="747238414788976867">"कस्टम"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"इतर ॲप्सवर फ्लोट करतात"</item>
+ <item msgid="3605616699204153590">"नेव्हिगेशन बार"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"लहान"</item>
+ <item msgid="1666628329913333563">"मोठा"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"पूर्व-शेअर की सह L2TP/IPSec VPN"</item>
diff --git a/res/values-ms/arrays.xml b/res/values-ms/arrays.xml
index 0dbd497..793f729 100644
--- a/res/values-ms/arrays.xml
+++ b/res/values-ms/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Kuning pada biru"</item>
<item msgid="747238414788976867">"Peribadi"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Terapung di atas apl lain"</item>
+ <item msgid="3605616699204153590">"Bar navigasi"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Kecil"</item>
+ <item msgid="1666628329913333563">"Besar"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"VPN L2TP/IPSec dengan kunci prakongsi"</item>
diff --git a/res/values-my/arrays.xml b/res/values-my/arrays.xml
index b425af6..ad7140e 100644
--- a/res/values-my/arrays.xml
+++ b/res/values-my/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"အပြာပေါ်အဝါ"</item>
<item msgid="747238414788976867">"စိတ်ကြိုက်"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"အခြားအက်ပ်များပေါ်တွင် မြင်ရခြင်း"</item>
+ <item msgid="3605616699204153590">"လမ်းညွှန်ဘား"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"သေး"</item>
+ <item msgid="1666628329913333563">"ကြီး"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"ကြိုတင် ပေးထားတဲ့ ကီးပါရှိသောL2TP/IPSec VPN"</item>
diff --git a/res/values-nb/arrays.xml b/res/values-nb/arrays.xml
index 02044dc..d893b40 100644
--- a/res/values-nb/arrays.xml
+++ b/res/values-nb/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Gult på blått"</item>
<item msgid="747238414788976867">"Egendefinert"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flytende over andre apper"</item>
+ <item msgid="3605616699204153590">"Navigasjonsrad"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Liten"</item>
+ <item msgid="1666628329913333563">"Stor"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN med forhåndsdelte nøkler"</item>
diff --git a/res/values-ne/arrays.xml b/res/values-ne/arrays.xml
index bacf02a..40e4b30 100644
--- a/res/values-ne/arrays.xml
+++ b/res/values-ne/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"नीलोमा पहेँलो"</item>
<item msgid="747238414788976867">"आफू अनुकूल"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"अन्य एपहरूमाथि तैरने"</item>
+ <item msgid="3605616699204153590">"नेभिगेसन बार"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"सानो"</item>
+ <item msgid="1666628329913333563">"ठुलो"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN पूर्व साझेदारी कुञ्जीकासँग"</item>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 4eb0afd..b2f9a89 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -21,7 +21,7 @@
<color name="homepage_support_background">#3F5FBD</color>
<color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
<color name="contextual_card_background">@*android:color/material_grey_900</color>
- <color name="search_bar_background">@*android:color/material_grey_800</color>
+ <color name="search_bar_background">@*android:color/material_grey_900</color>
<!-- Dialog background color. -->
<color name="dialog_background">@*android:color/material_grey_800</color>
<color name="notification_importance_selection_bg">@*android:color/material_grey_800</color>
diff --git a/res/values-nl/arrays.xml b/res/values-nl/arrays.xml
index 627fa59..eafae00 100644
--- a/res/values-nl/arrays.xml
+++ b/res/values-nl/arrays.xml
@@ -274,7 +274,7 @@
<item msgid="2297727967385895059">"locatie met hoog energieverbruik controleren"</item>
<item msgid="8700593962030471569">"gebruiksstatistieken ophalen"</item>
<item msgid="4140820386622184831">"microfoon uit-/aanzetten"</item>
- <item msgid="317746827951691657">"toast weergeven"</item>
+ <item msgid="317746827951691657">"toast tonen"</item>
<item msgid="5679422988212309779">"media projecteren"</item>
<item msgid="6454031639780101439">"VPN activeren"</item>
<item msgid="2441327072846850561">"achtergrond schrijven"</item>
@@ -341,7 +341,7 @@
<item msgid="5186169827582545242">"Locatie"</item>
<item msgid="6122293931012635638">"Gebruiksstatistieken ophalen"</item>
<item msgid="2526677383312751932">"Microfoon uit-/aanzetten"</item>
- <item msgid="4000577305179914546">"Toast weergeven"</item>
+ <item msgid="4000577305179914546">"Toast tonen"</item>
<item msgid="8660207174515570558">"Media projecteren"</item>
<item msgid="3904996949561946108">"VPN activeren"</item>
<item msgid="504052124101832515">"Achtergrond schrijven"</item>
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Geel op blauw"</item>
<item msgid="747238414788976867">"Aangepast"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Zwevend over andere apps"</item>
+ <item msgid="3605616699204153590">"Navigatiebalk"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Klein"</item>
+ <item msgid="1666628329913333563">"Groot"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP-VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec-VPN met van tevoren gedeelde sleutels"</item>
diff --git a/res/values-or/arrays.xml b/res/values-or/arrays.xml
index 10a8ca8..dfdaa2e 100644
--- a/res/values-or/arrays.xml
+++ b/res/values-or/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"ନୀଳ ଉପରେ ହଳଦିଆ"</item>
<item msgid="747238414788976867">"କଷ୍ଟମ୍"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"ଅନ୍ୟ ଆପଗୁଡ଼ିକ ଉପରେ ଫ୍ଲୋଟ୍ ହେଉଛି"</item>
+ <item msgid="3605616699204153590">"ନାଭିଗେସନ୍ ବାର୍"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"ଛୋଟ"</item>
+ <item msgid="1666628329913333563">"ବଡ଼"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"ପୂର୍ବରୁ ସେୟାର୍ ହୋଇଥିବା କୀଗୁଡ଼ିକ ସହ L2TP/IPSec VPN"</item>
diff --git a/res/values-pa/arrays.xml b/res/values-pa/arrays.xml
index b19666c..4838f68 100644
--- a/res/values-pa/arrays.xml
+++ b/res/values-pa/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"ਨੀਲੇ \'ਤੇ ਪੀਲਾ"</item>
<item msgid="747238414788976867">"ਵਿਉਂਂਤੀ"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"ਦੂਜੀਆਂ ਐਪਾਂ \'ਤੇ ਫ਼ਲੋਟ ਕਰਨਾ"</item>
+ <item msgid="3605616699204153590">"ਦਿਸ਼ਾ-ਨਿਰਦੇਸ਼ ਪੱਟੀ"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"ਛੋਟਾ"</item>
+ <item msgid="1666628329913333563">"ਵੱਡਾ"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"ਪ੍ਰੀ-ਸ਼ੇਅਰ ਕੀਤੀਆਂ ਕੁੰਜੀਆਂ ਨਾਲ L2TP/IPSec VPN"</item>
diff --git a/res/values-pl/arrays.xml b/res/values-pl/arrays.xml
index 4a47bac..518e302 100644
--- a/res/values-pl/arrays.xml
+++ b/res/values-pl/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Żółty na niebieskim"</item>
<item msgid="747238414788976867">"Niestandardowy"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Pływający nad innymi aplikacjami"</item>
+ <item msgid="3605616699204153590">"Pasek nawigacyjny"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Mały"</item>
+ <item msgid="1666628329913333563">"Duży"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"Sieć VPN wykorzystująca protokół PPTP"</item>
<item msgid="2552427673212085780">"Sieć VPN wykorzystująca protokół L2TP/IPSec z kluczami wspólnymi"</item>
diff --git a/res/values-pt-rBR/arrays.xml b/res/values-pt-rBR/arrays.xml
index 58b4e61..640ebbd 100644
--- a/res/values-pt-rBR/arrays.xml
+++ b/res/values-pt-rBR/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Amarelo em azul"</item>
<item msgid="747238414788976867">"Personalizado"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flutuando sobre outros apps"</item>
+ <item msgid="3605616699204153590">"Barra de navegação"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Pequeno"</item>
+ <item msgid="1666628329913333563">"Grande"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN com chaves pré-compartilhadas"</item>
diff --git a/res/values-pt-rPT/arrays.xml b/res/values-pt-rPT/arrays.xml
index d387923..1937541 100644
--- a/res/values-pt-rPT/arrays.xml
+++ b/res/values-pt-rPT/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Amarelo em azul"</item>
<item msgid="747238414788976867">"Personalizado"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flutuante sobre outras apps"</item>
+ <item msgid="3605616699204153590">"Barra de navegação"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Pequeno"</item>
+ <item msgid="1666628329913333563">"Grande"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"VPN L2TP/IPSec com chaves pré-partilhadas"</item>
diff --git a/res/values-pt/arrays.xml b/res/values-pt/arrays.xml
index 58b4e61..640ebbd 100644
--- a/res/values-pt/arrays.xml
+++ b/res/values-pt/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Amarelo em azul"</item>
<item msgid="747238414788976867">"Personalizado"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flutuando sobre outros apps"</item>
+ <item msgid="3605616699204153590">"Barra de navegação"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Pequeno"</item>
+ <item msgid="1666628329913333563">"Grande"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN com chaves pré-compartilhadas"</item>
diff --git a/res/values-ro/arrays.xml b/res/values-ro/arrays.xml
index c4c6284..4f282e2 100644
--- a/res/values-ro/arrays.xml
+++ b/res/values-ro/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Galben pe albastru"</item>
<item msgid="747238414788976867">"Personalizat"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Se afișează peste alte aplicații"</item>
+ <item msgid="3605616699204153590">"Bară de navigare"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Mic"</item>
+ <item msgid="1666628329913333563">"Mare"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN cu chei predistribuite"</item>
diff --git a/res/values-ru/arrays.xml b/res/values-ru/arrays.xml
index 98d2439..cdcf10b 100644
--- a/res/values-ru/arrays.xml
+++ b/res/values-ru/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Желтый на синем"</item>
<item msgid="747238414788976867">"Специальный"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Поверх других приложений"</item>
+ <item msgid="3605616699204153590">"Панель навигации"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Маленькая кнопка"</item>
+ <item msgid="1666628329913333563">"Большая кнопка"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN-подключение по протоколу PPTP"</item>
<item msgid="2552427673212085780">"VPN-соединение по протоколу L2TP/IPSec с общими ключами"</item>
diff --git a/res/values-si/arrays.xml b/res/values-si/arrays.xml
index f3944d9..c0f8dbb 100644
--- a/res/values-si/arrays.xml
+++ b/res/values-si/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"නිල් මත කහ"</item>
<item msgid="747238414788976867">"අභිරුචි"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"යෙදුම්වලට උඩින් පාවීම"</item>
+ <item msgid="3605616699204153590">"සංචලන තීරුව"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"කුඩා"</item>
+ <item msgid="1666628329913333563">"විශාල"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"පෙර බෙදාගත් යතුරු සමඟ L2TP/IPSec VPN"</item>
diff --git a/res/values-sk/arrays.xml b/res/values-sk/arrays.xml
index 5ec1c81..2d6e38a 100644
--- a/res/values-sk/arrays.xml
+++ b/res/values-sk/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Žlté na modrom"</item>
<item msgid="747238414788976867">"Vlastné"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Plávajúce nad ostatnými aplikáciami"</item>
+ <item msgid="3605616699204153590">"Navigačný panel"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Malé"</item>
+ <item msgid="1666628329913333563">"Veľké"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN s protokolom PPTP"</item>
<item msgid="2552427673212085780">"Sieť VPN založená na protokole L2TP/IPSec s predzdieľanými kľúčmi"</item>
diff --git a/res/values-sl/arrays.xml b/res/values-sl/arrays.xml
index 8ed2d74..9931395 100644
--- a/res/values-sl/arrays.xml
+++ b/res/values-sl/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Rumeno na modrem"</item>
<item msgid="747238414788976867">"Po meri"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Prekrivanje drugih aplikacij"</item>
+ <item msgid="3605616699204153590">"Vrstica za krmarjenje"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Majhen"</item>
+ <item msgid="1666628329913333563">"Velik"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN s ključi v predhodni skupni rabi"</item>
diff --git a/res/values-sq/arrays.xml b/res/values-sq/arrays.xml
index 9a348bf..4ade61a 100644
--- a/res/values-sq/arrays.xml
+++ b/res/values-sq/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"E verdhë mbi të kaltër"</item>
<item msgid="747238414788976867">"Të personalizuara"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Pluskon mbi aplikacionet e tjera"</item>
+ <item msgid="3605616699204153590">"Shiriti i navigimit"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"I vogël"</item>
+ <item msgid="1666628329913333563">"I madh"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"VPN PPTP"</item>
<item msgid="2552427673212085780">"Rrjeti VPN L2TP/IPSec me çelësat e ndarë paraprakisht"</item>
diff --git a/res/values-sr/arrays.xml b/res/values-sr/arrays.xml
index 18bf8fe..ca536c9 100644
--- a/res/values-sr/arrays.xml
+++ b/res/values-sr/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Жуто на плаво"</item>
<item msgid="747238414788976867">"Прилагођено"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Плута преко других апликација"</item>
+ <item msgid="3605616699204153590">"Трака за навигацију"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Мала"</item>
+ <item msgid="1666628329913333563">"Велика"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN са унапред дељеним кључевима"</item>
diff --git a/res/values-sv/arrays.xml b/res/values-sv/arrays.xml
index 5d3dc63..365e4fa 100644
--- a/res/values-sv/arrays.xml
+++ b/res/values-sv/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Gult på blått"</item>
<item msgid="747238414788976867">"Anpassat"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Flytande över andra appar"</item>
+ <item msgid="3605616699204153590">"Navigeringsfält"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Liten"</item>
+ <item msgid="1666628329913333563">"Stor"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP-VPN"</item>
<item msgid="2552427673212085780">"L2TP-/IPSec-VPN med nycklar som delats i förväg"</item>
diff --git a/res/values-sw/arrays.xml b/res/values-sw/arrays.xml
index 89fb40c..0dd92d5 100644
--- a/res/values-sw/arrays.xml
+++ b/res/values-sw/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Manjano kwenye samawati"</item>
<item msgid="747238414788976867">"Maalum"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Kuelea juu ya programu zingine"</item>
+ <item msgid="3605616699204153590">"Sehemu ya viungo muhimu"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Kidogo"</item>
+ <item msgid="1666628329913333563">"Kikubwa"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN na vitufe vilivyoshirikishwa kabla"</item>
diff --git a/res/values-ta/arrays.xml b/res/values-ta/arrays.xml
index e5c4a79..96f97c0 100644
--- a/res/values-ta/arrays.xml
+++ b/res/values-ta/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"நீலத்தில் மஞ்சள்"</item>
<item msgid="747238414788976867">"பிரத்தியேகம்"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"பிற ஆப்ஸ் மீது தோன்றுதல்"</item>
+ <item msgid="3605616699204153590">"வழிசெலுத்தல் பட்டி"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"சிறியது"</item>
+ <item msgid="1666628329913333563">"பெரியது"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"பாதுகாப்பு விசைகளுடன் கூடிய L2TP/IPSec VPN"</item>
diff --git a/res/values-te/arrays.xml b/res/values-te/arrays.xml
index 18bb6bc..00a56f7 100644
--- a/res/values-te/arrays.xml
+++ b/res/values-te/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"నీలి నేపథ్యంలో పసుపు రంగు"</item>
<item msgid="747238414788976867">"అనుకూలం"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"ఇతర యాప్ల మీద తేలియాడుతోంది"</item>
+ <item msgid="3605616699204153590">"నావిగేషన్ బార్"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"చిన్నది"</item>
+ <item msgid="1666628329913333563">"పెద్దది"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"పూర్వ-భాగస్వామ్య కీలతో L2TP/IPSec VPN"</item>
diff --git a/res/values-th/arrays.xml b/res/values-th/arrays.xml
index 1e4de9c3..a659bda 100644
--- a/res/values-th/arrays.xml
+++ b/res/values-th/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"สีเหลืองบนพื้นสีน้ำเงิน"</item>
<item msgid="747238414788976867">"กำหนดเอง"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"ลอยเหนือแอปอื่นๆ"</item>
+ <item msgid="3605616699204153590">"แถบนำทาง"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"เล็ก"</item>
+ <item msgid="1666628329913333563">"ใหญ่"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN พร้อมด้วยคีย์ที่แชร์ไว้ล่วงหน้า"</item>
diff --git a/res/values-tl/arrays.xml b/res/values-tl/arrays.xml
index 938eff5..b65b170 100644
--- a/res/values-tl/arrays.xml
+++ b/res/values-tl/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Dilaw sa asul"</item>
<item msgid="747238414788976867">"Custom"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Nasa ibabaw ng iba pang app"</item>
+ <item msgid="3605616699204153590">"Navigation bar"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Maliit"</item>
+ <item msgid="1666628329913333563">"Malaki"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN na may mga paunang nabahaging key"</item>
diff --git a/res/values-tr/arrays.xml b/res/values-tr/arrays.xml
index 5ed1d6c..c55df18 100644
--- a/res/values-tr/arrays.xml
+++ b/res/values-tr/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Mavi üzerine sarı"</item>
<item msgid="747238414788976867">"Özel"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Diğer uygulamaların üzerinde kayan"</item>
+ <item msgid="3605616699204153590">"Gezinme çubuğu"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Küçük"</item>
+ <item msgid="1666628329913333563">"Büyük"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"Önceden paylaşılan anahtara sahip L2TP/IPSec VPN"</item>
diff --git a/res/values-uk/arrays.xml b/res/values-uk/arrays.xml
index 5bbc7ac..9c85a16 100644
--- a/res/values-uk/arrays.xml
+++ b/res/values-uk/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Жовтий на синьому"</item>
<item msgid="747238414788976867">"Спеціальний"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Плаває поверх інших додатків"</item>
+ <item msgid="3605616699204153590">"Панель навігації"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Мала"</item>
+ <item msgid="1666628329913333563">"Велика"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN зі спільними ключами"</item>
diff --git a/res/values-ur/arrays.xml b/res/values-ur/arrays.xml
index a336c3c..4e5af0b 100644
--- a/res/values-ur/arrays.xml
+++ b/res/values-ur/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"نیلے پر پیلا"</item>
<item msgid="747238414788976867">"حسب ضرورت"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"دیگر ایپس پر فلوٹنگ ہو رہی ہے"</item>
+ <item msgid="3605616699204153590">"نیویگیشن بار"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"چھوٹا"</item>
+ <item msgid="1666628329913333563">"بڑا"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"پہلے سے اشتراک کردہ کلیدوں کے ساتھ L2TP/IPSec VPN"</item>
diff --git a/res/values-uz/arrays.xml b/res/values-uz/arrays.xml
index 56f7063..c24ba87 100644
--- a/res/values-uz/arrays.xml
+++ b/res/values-uz/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Ko‘k ustida sariq"</item>
<item msgid="747238414788976867">"Maxsus"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Boshqa ilovalar ustidan chiqishi"</item>
+ <item msgid="3605616699204153590">"Navigatsiya paneli"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Kichik"</item>
+ <item msgid="1666628329913333563">"Yirik"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN avval ulashilgan kalitlar bilan"</item>
diff --git a/res/values-vi/arrays.xml b/res/values-vi/arrays.xml
index ad319ac..a1158fc 100644
--- a/res/values-vi/arrays.xml
+++ b/res/values-vi/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Chữ vàng trên nền xanh lam"</item>
<item msgid="747238414788976867">"Tùy chỉnh"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Nổi trên các ứng dụng khác"</item>
+ <item msgid="3605616699204153590">"Thanh điều hướng"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Nhỏ"</item>
+ <item msgid="1666628329913333563">"Lớn"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN có khóa chia sẻ trước"</item>
diff --git a/res/values-zh-rCN/arrays.xml b/res/values-zh-rCN/arrays.xml
index 19deb1e..073df09 100644
--- a/res/values-zh-rCN/arrays.xml
+++ b/res/values-zh-rCN/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"蓝底黄字"</item>
<item msgid="747238414788976867">"自定义"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"悬浮在其他应用的上层"</item>
+ <item msgid="3605616699204153590">"导航栏"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"小"</item>
+ <item msgid="1666628329913333563">"大"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"具有预共享密钥的 L2TP/IPSec VPN"</item>
diff --git a/res/values-zh-rHK/arrays.xml b/res/values-zh-rHK/arrays.xml
index e876134..a91a444 100644
--- a/res/values-zh-rHK/arrays.xml
+++ b/res/values-zh-rHK/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"藍底黃字"</item>
<item msgid="747238414788976867">"自訂"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"浮動顯示在其他應用程式上"</item>
+ <item msgid="3605616699204153590">"導覽列"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"小"</item>
+ <item msgid="1666628329913333563">"大"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN (預先共用密鑰)"</item>
diff --git a/res/values-zh-rTW/arrays.xml b/res/values-zh-rTW/arrays.xml
index dee72bc..1a49712 100644
--- a/res/values-zh-rTW/arrays.xml
+++ b/res/values-zh-rTW/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"藍底黃字"</item>
<item msgid="747238414788976867">"自訂"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"浮動顯示在其他應用程式上"</item>
+ <item msgid="3605616699204153590">"導覽列"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"小"</item>
+ <item msgid="1666628329913333563">"大"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"L2TP/IPSec VPN (預先共用金鑰)"</item>
diff --git a/res/values-zu/arrays.xml b/res/values-zu/arrays.xml
index 40edd11..26d2e8b 100644
--- a/res/values-zu/arrays.xml
+++ b/res/values-zu/arrays.xml
@@ -419,6 +419,14 @@
<item msgid="2836895041823327816">"Okuliphuzi kokuluhlaza"</item>
<item msgid="747238414788976867">"Ngokwezifiso"</item>
</string-array>
+ <string-array name="accessibility_button_location_selector_titles">
+ <item msgid="6485511780196327736">"Intanta phezu kwamanye ama-app"</item>
+ <item msgid="3605616699204153590">"Ibha yokuzula"</item>
+ </string-array>
+ <string-array name="accessibility_button_size_selector_titles">
+ <item msgid="7482952318152486459">"Esincane"</item>
+ <item msgid="1666628329913333563">"Esikhulu"</item>
+ </string-array>
<string-array name="vpn_types_long">
<item msgid="6621806338070912611">"PPTP VPN"</item>
<item msgid="2552427673212085780">"i-L2TP/IPSec VPN nokhiye okwabeliswaniwa ngabo"</item>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index dbf21fc..e0e0219 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -131,25 +131,21 @@
<dimen name="switchbar_subsettings_margin_start">72dp</dimen>
<dimen name="switchbar_subsettings_margin_end">16dp</dimen>
- <!-- Search bar and avatar -->
- <dimen name="search_bar_margin">24dp</dimen>
- <dimen name="search_bar_margin_bottom">16dp</dimen>
- <dimen name="search_bar_height">48dp</dimen>
- <dimen name="search_bar_text_size">16sp</dimen>
- <dimen name="search_bar_card_elevation">2dp</dimen>
- <dimen name="search_bar_content_inset">64dp</dimen>
- <dimen name="avatar_length">@dimen/search_bar_height</dimen>
+ <!-- Search bar -->
+ <dimen name="search_bar_margin">16dp</dimen>
+ <dimen name="search_bar_height">52dp</dimen>
+ <dimen name="search_bar_text_size">20sp</dimen>
+ <dimen name="search_bar_corner_radius">28dp</dimen>
+ <dimen name="search_bar_content_inset">56dp</dimen>
- <!-- Contextual suggestions -->
- <dimen name="suggestion_height">232dp</dimen>
- <dimen name="suggestion_padding_horizontal">24dp</dimen>
- <dimen name="suggestion_padding_vertical">8dp</dimen>
- <dimen name="suggestion_button_margin_top">16dp</dimen>
- <dimen name="suggestion_button_padding_horizontal">24dp</dimen>
+ <!-- Avatar -->
+ <dimen name="avatar_length">48dp</dimen>
+ <dimen name="avatar_margin_top">56dp</dimen>
+ <dimen name="avatar_margin_end">24dp</dimen>
- <!-- Tool bar text -->
- <dimen name="tool_bar_max_text_size">36sp</dimen>
- <dimen name="tool_bar_min_text_size">24sp</dimen>
+ <!-- Homepage title -->
+ <dimen name="homepage_title_margin_bottom">8dp</dimen>
+ <dimen name="homepage_title_margin_horizontal">24dp</dimen>
<!-- Dimensions for Wifi Assistant Card -->
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>
@@ -295,6 +291,7 @@
<!-- Accessibility Settings -->
<dimen name="accessibility_layout_margin_start_end">16dp</dimen>
<dimen name="accessibility_button_preference_padding_top_bottom">18dp</dimen>
+ <dimen name="accessibility_imageview_size">176dp</dimen>
<!-- Restricted icon in switch bar -->
<dimen name="restricted_icon_margin_end">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 78fb0a9..50a8eea 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2959,6 +2959,8 @@
<string name="wallpaper_settings_title">Wallpaper</string>
<!-- Styles & Wallpapers settings title [CHAR LIMIT=30] -->
<string name="style_and_wallpaper_settings_title">Styles & wallpapers</string>
+ <!-- Summary for the top level Styles & wallpapers Settings [CHAR LIMIT=NONE]-->
+ <string name="wallpaper_dashboard_summary">Colors, app grid</string>
<!-- Wallpaper settings summary when default wallpaper is used [CHAR LIMIT=NONE] -->
<string name="wallpaper_settings_summary_default">Default</string>
<!-- Wallpaper settings summary when wallpaper has been updated [CHAR LIMIT=NONE] -->
@@ -3368,6 +3370,10 @@
<string name="storage_menu_manage">Manage storage</string>
<!-- Storage setting. Keywords for Free up space. [CHAR LIMIT=NONE] -->
<string name="keywords_storage_menu_free">clean, storage</string>
+ <!-- Storage setting. Title for storage free up option. [CHAR LIMIT=30] -->
+ <string name="storage_free_up_space_title">Free up space</string>
+ <!-- Storage setting. Summary for storage free up option. [CHAR LIMIT=NONE] -->
+ <string name="storage_free_up_space_summary">Go to Files app to manage and free up space</string>
<!-- Storage setting. Title for USB transfer settings [CHAR LIMIT=30]-->
<string name="storage_title_usb">USB computer connection</string>
@@ -5039,7 +5045,7 @@
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
<string name="accessibility_screen_magnification_title">Magnification</string>
<!-- Title for the accessibility preference screen to edit magnification area. [CHAR LIMIT=35] -->
- <string name="accessibility_magnification_mode_title">Choose how to magnify</string>
+ <string name="accessibility_magnification_mode_title">Magnification type</string>
<!-- Message for the accessibility preference screen to edit magnification area dialog. [CHAR LIMIT=none] -->
<string name="accessibility_magnification_area_settings_message">Magnify your full screen, a specific area, or switch between both options</string>
<!-- Summary for the accessibility preference screen to edit full screen. [CHAR LIMIT=none] -->
@@ -5048,10 +5054,16 @@
<string name="accessibility_magnification_area_settings_window_screen_summary">Partial screen</string>
<!-- Summary for the accessibility preference screen to edit full and partial screen. [CHAR LIMIT=none] -->
<string name="accessibility_magnification_area_settings_all_summary">Switch between full and partial screen</string>
- <!-- Message for the accessibility preference screen to edit the full screen. [CHAR LIMIT=none] -->
- <string name="accessibility_magnification_area_settings_full_screen">Magnify full screen</string>
- <!-- Message for the accessibility preference screen to edit part of screen. [CHAR LIMIT=none] -->
- <string name="accessibility_magnification_area_settings_window_screen">Magnify part of screen</string>
+ <!-- dialog title for magnification mode selection. [CHAR LIMIT=35] -->
+ <string name="accessibility_magnification_mode_dialog_title">Choose how to magnify</string>
+ <!-- Option title of full-screen magnification mode in the mode selection dialog. [CHAR LIMIT=50] -->
+ <string name="accessibility_magnification_mode_dialog_option_full_screen">Magnify full screen</string>
+ <!-- Option title of window magnification mode in the mode selection dialog. [CHAR LIMIT=50] -->
+ <string name="accessibility_magnification_mode_dialog_option_window">Magnify part of screen</string>
+ <!-- Option title of full magnification mode in the mode selection dialog. [CHAR LIMIT=50] -->
+ <string name="accessibility_magnification_mode_dialog_option_switch">Switch between full and partial screen</string>
+ <!-- Message of the magnification mode option to choose the magnification mode. [CHAR LIMIT=none] -->
+ <string name="accessibility_magnification_area_settings_mode_switch_summary">Tap the switch button to move between both options</string>
<!-- Title for the accessibility magnification switch shortcut dialog. [CHAR LIMIT=48] -->
<string name="accessibility_magnification_switch_shortcut_title">Switch to accessibility button?</string>
<!-- Message for the accessibility magnification switch shortcut dialog. [CHAR LIMIT=none] -->
@@ -7044,6 +7056,8 @@
<string name="vpn_always_on_summary_not_supported">Not supported by this app</string>
<!-- Preference summary for a VPN app that is set to be always-on. [CHAR LIMIT=40] -->
<string name="vpn_always_on_summary_active">Always-on active</string>
+ <!-- Preference summary for a VPN app that has an insecure type. [CHAR LIMIT=40] -->
+ <string name="vpn_insecure_summary">not secure VPN</string>
<!-- Preference title for the toggle that controls whether to force all network connections to
go through VPN. [CHAR LIMIT=40] -->
<string name="vpn_require_connection">Block connections without VPN</string>
@@ -7051,6 +7065,9 @@
[CHAR LIMIT=40] -->
<string name="vpn_require_connection_title">Require VPN connection?</string>
+ <!-- Dialog subtitle warning for a VPN app that has an insecure type. [CHAR LIMIT=100] -->
+ <string name="vpn_insecure_dialog_subtitle">This VPN is not secure. Update to an IKEv2 VPN</string>
+
<!-- Summary describing the always-on VPN feature. [CHAR LIMIT=NONE] -->
<string name="vpn_lockdown_summary">Select a VPN profile to always remain connected to. Network traffic will only be allowed when connected to this VPN.</string>
<!-- List item indicating that no always-on VPN is selected. [CHAR LIMIT=64] -->
@@ -7257,6 +7274,12 @@
<!-- Summary for the emergency info preference [CHAR LIMIT=40] -->
<string name="emergency_info_summary">Info & contacts for <xliff:g id="user_name" example="Jason">%1$s</xliff:g></string>
+ <!-- Button label for opening an arbitrary app [CHAR LIMIT=60] -->
+ <string name="open_app_button">Open <xliff:g id="app_name" example="Safety">%1$s</xliff:g></string>
+
+ <!-- Title for more settings button, clicking this button will open a new page containing more settings related to current page. [CHAR LIMIT=60] -->
+ <string name="more_settings_button">More Settings</string>
+
<!-- Application Restrictions screen title [CHAR LIMIT=45] -->
<string name="application_restrictions">Allow apps and content</string>
<!-- Applications with restrictions header [CHAR LIMIT=45] -->
@@ -7361,6 +7384,8 @@
<string name="help_uri_apps_wifi_access" translatable="false"></string>
<!-- Help URI, manage apps that have access to all files [DO NOT TRANSLATE] -->
<string name="help_uri_manage_external_storage" translatable="false"></string>
+ <!-- Help URI, manage apps that can modify media files [DO NOT TRANSLATE] -->
+ <string name="help_uri_media_management_apps" translatable="false"></string>
<!-- Help URI, Storage [DO NOT TRANSLATE] -->
<string name="help_uri_storage" translatable="false"></string>
<!-- Help URI, Accessibility [DO NOT TRANSLATE] -->
@@ -7486,6 +7511,8 @@
<string name="help_uri_nfc_and_payment_settings" translatable="false"></string>
<!-- url for battery page if battery is not present -->
<string name="help_url_battery_missing" translatable="false"></string>
+ <!-- url for vpn page if connected vpn is not a secure type -->
+ <string name="help_url_insecure_vpn" translatable="false"></string>
<!-- User account title [CHAR LIMIT=30] -->
<string name="user_account_title">Account for content</string>
@@ -7752,8 +7779,8 @@
<string name="app_and_notification_dashboard_summary">Recent apps, default apps</string>
<!-- Toast shown when an app in the work profile attempts to open notification settings. The apps in the work profile cannot access notification settings. [CHAR LIMIT=NONE] -->
<string name="notification_settings_work_profile">Notification access is not available for apps in the work profile.</string>
- <!-- Title for setting tile leading to account settings [CHAR LIMIT=40]-->
- <string name="account_dashboard_title">Accounts</string>
+ <!-- Title for setting tile leading to saved autofill passwords, autofill , and account settings [CHAR LIMIT=40]-->
+ <string name="account_dashboard_title">Passwords and accounts</string>
<!-- Summary for account settings tiles when there is no accounts on device [CHAR LIMIT=NONE]-->
<string name="account_dashboard_default_summary">No accounts added</string>
<!-- Title for setting tile leading to setting UI which allows user set default app to
@@ -8375,6 +8402,9 @@
<!-- Configure Notifications Settings title. [CHAR LIMIT=30] -->
<string name="configure_notification_settings">Notifications</string>
+ <!-- Summary for the top level Notifications Settings [CHAR LIMIT=NONE]-->
+ <string name="notification_dashboard_summary">Notification history, conversations</string>
+
<!-- notification header - settings for conversation type notifications -->
<string name="conversation_notifs_category">Conversation</string>
@@ -9558,6 +9588,9 @@
settings button -->
<string name="notification_app_settings_button">Notification settings</string>
+ <!-- Content description for help icon button [CHAR LIMIT=20] -->
+ <string name="warning_button_text">Warning</string>
+
<!-- Generic label for suggestion card's ok button [CHAR LIMIT=20] -->
<string name="suggestion_button_text">Ok</string>
@@ -10363,6 +10396,15 @@
<!-- Label for showing apps that can manage external storage[CHAR LIMIT=45] -->
<string name="filter_manage_external_storage">Can access all files</string>
+ <!-- Media management apps settings title [CHAR LIMIT=40] -->
+ <string name="media_management_apps_title">Media management apps</string>
+ <!-- Label for a setting which controls whether an app can manage media files [CHAR LIMIT=45] -->
+ <string name="media_management_apps_toggle_label">Allow app to manage media files</string>
+ <!-- Description for a setting which controls whether an app can manage media files [CHAR LIMIT=NONE] -->
+ <string name="media_management_apps_description">If allowed, this app can modify or delete media files on this device or connected storage device without asking you. App must have permission to access files and media.</string>
+ <!-- Search keywords for media management apps settings [CHAR_LIMIT=NONE] -->
+ <string name="keywords_media_management_apps">Media, File, Management, Manager, Manage, Edit, Editor, App, Application, Program</string>
+
<!-- Keyword for VR setting -->
<string name="keywords_vr_listener">vr virtual reality listener stereo helper service</string>
<!-- Main settings screen item's title to go into the overlay settings screen [CHAR LIMIT=30] -->
@@ -10498,6 +10540,9 @@
<!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
<string name="display_dashboard_summary_with_style">Styles, wallpapers, screen timeout, font size</string>
+ <!-- Summary for the top level Display Settings [CHAR LIMIT=NONE]-->
+ <string name="display_dashboard_summary_2">Screen timeout, font size</string>
+
<!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
<string name="display_dashboard_nowallpaper_summary">Sleep, font size</string>
@@ -11196,6 +11241,9 @@
<!-- Preference title for "Safety & emergency" settings page [CHAR LIMIT=60]-->
<string name="emergency_settings_preference_title">Safety & emergency</string>
+ <!-- Summary for the top level Safety & emergency Settings [CHAR LIMIT=NONE]-->
+ <string name="emergency_dashboard_summary">Emergency SOS, medical info, alerts</string>
+
<!-- Title text for edge to edge navigation [CHAR LIMIT=60] -->
<string name="edge_to_edge_navigation_title">Gesture navigation</string>
<!-- Summary text for edge to edge navigation [CHAR LIMIT=NONE] -->
@@ -11249,8 +11297,8 @@
<!-- Title text for swiping downwards on the bottom of the screen for notifications [CHAR LIMIT=60]-->
<string name="swipe_bottom_to_notifications_title">Swipe for notifications</string>
- <!-- Summary text for swiping downwards on the bottom of the screen for notifications [CHAR LIMIT=80]-->
- <string name="swipe_bottom_to_notifications_summary">Swipe down on the bottom edge of the screen to show your notifications</string>
+ <!-- Summary text for swiping downwards on the bottom of the screen for notifications [CHAR LIMIT=NONE]-->
+ <string name="swipe_bottom_to_notifications_summary">Swipe down on the bottom edge of the screen to show your notifications.\nYou can\'t use one-handed mode when this feature is turned on.</string>
<!-- Preference and settings suggestion title text for one handed [CHAR LIMIT=60] -->
<string name="one_handed_title">One-Handed mode</string>
@@ -11505,6 +11553,25 @@
<!-- Button label to allow the user to view additional information [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=2416766240581561009] -->
<string name="learn_more">Learn more</string>
+ <!-- Financed device Privacy --> <skip />
+
+ <!-- Title of setting on security settings screen on a financed device. This will take the user to a screen with information about what a device administrator can control and their impact on the user's privacy on a financed device. Shown on financed-managed devices only. [CHAR LIMIT=NONE] -->
+ <string name="financed_privacy_settings">Financed device info</string>
+ <!-- Section header. This section shows what information a device administrator can see on a financed device. [CHAR LIMIT=60] -->
+ <string name="financed_privacy_exposure_category">Types of information your device administrator can see</string>
+ <!-- Label explaining that the device administrator can see data associated on the user's financed device. [CHAR LIMIT=NONE] -->
+ <string name="financed_privacy_data">Data associated with your account, such as email and calendar info</string>
+ <!-- Section header. This section shows what changes a device administrator made to a financed device. [CHAR LIMIT=60] -->
+ <string name="financed_privacy_exposure_changes_category">Changes made by your device administrator</string>
+ <!-- Label explaining that the device admin can lock the device and change the user's password on their financed device. [CHAR LIMIT=NONE] -->
+ <string name="financed_privacy_lock_device">Device administrator can lock this device and reset password</string>
+ <!-- Label explaining that the device admin can wipe the device remotely for a financed device. [CHAR LIMIT=NONE] -->
+ <string name="financed_privacy_wipe_device">Device administrator can delete all device data</string>
+ <!-- Label explaining that the device admin configured the device to wipe itself when an incorrect password is entered too many times on a financed device. [CHAR LIMIT=NONE] -->
+ <string name="financed_privacy_failed_password_wipe_device">Failed password attempts before deleting device data</string>
+ <!-- Financed Privacy settings activity header, summarizing the changes a credit provider can make to a financed device. [CHAR LIMIT=NONE] -->
+ <string name="financed_privacy_header">Your credit provider can change settings and install software on this device.\n\nTo learn more, contact your creditor provider.</string>
+
<!-- Strings for displaying which applications were set as default for specific actions. -->
<!-- Title for the apps that have been set as default handlers of camera-related intents. [CHAR LIMIT=30] -->
<plurals name="default_camera_app_title">
@@ -11547,6 +11614,39 @@
<!-- Preference label for the Files storage section. [CHAR LIMIT=50] -->
<string name="storage_files">Files</string>
+ <!-- Preference label for the Images storage section. [CHAR LIMIT=50] -->
+ <string name="storage_images">Images</string>
+
+ <!-- Preference label for the Videos storage section. [CHAR LIMIT=50] -->
+ <string name="storage_videos">Videos</string>
+
+ <!-- Preference label for the Audios storage section. [CHAR LIMIT=50] -->
+ <string name="storage_audios">Audios</string>
+
+ <!-- Preference label for the Apps storage section. [CHAR LIMIT=50] -->
+ <string name="storage_apps">Apps</string>
+
+ <!-- Preference label for the Documents & other storage section. [CHAR LIMIT=50] -->
+ <string name="storage_documents_and_other">Documents & other</string>
+
+ <!-- Preference label for the System storage section. [CHAR LIMIT=50] -->
+ <string name="storage_system">System</string>
+
+ <!-- Preference label for the Trash storage section. [CHAR LIMIT=50] -->
+ <string name="storage_trash">Trash</string>
+
+ <!-- Dialog title for the Trash storage section. [CHAR LIMIT=50] -->
+ <string name="storage_trash_dialog_title">Empty trash?</string>
+
+ <!-- Dialog message for the Trash storage section. [CHAR LIMIT=NONE] -->
+ <string name="storage_trash_dialog_ask_message">There are <xliff:g id="total" example="520MB">%1$s</xliff:g> of files in the trash. All items will be deleted forever, and you won\u2019t be able to restore them.</string>
+
+ <!-- Dialog message for the Trash storage section. [CHAR LIMIT=NONE] -->
+ <string name="storage_trash_dialog_empty_message">Trash is empty</string>
+
+ <!-- Dialog confirm button to empty all trash files. [CHAR LIMIT=50] -->
+ <string name="storage_trash_dialog_confirm">Empty trash</string>
+
<!-- Summary of a single storage volume used space. [CHAR LIMIT=24] -->
<string name="storage_size_large_alternate"><xliff:g id="number" example="128">^1</xliff:g><small> <font size="20"><xliff:g id="unit" example="KB">^2</xliff:g></font></small></string>
<!-- Summary of a single storage volume total space. [CHAR LIMIT=48]-->
@@ -11554,6 +11654,10 @@
<!-- Follows the percent of storage used by a storage volume. Exposed inside of a donut graph. [CHAR LIMIT=7]-->
<string name="storage_percent_full">used</string>
+ <!-- Summary of a single storage volume used space. [CHAR LIMIT=24] -->
+ <string name="storage_usage_summary"><xliff:g id="number" example="128">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g> used</string>
+ <!-- Summary of a single storage volume total space. [CHAR LIMIT=24] -->
+ <string name="storage_total_summary">Total <xliff:g id="number" example="128">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g></string>
<!-- Label for button allow user to remove the instant app from the device. -->
<string name="clear_instant_app_data">Clear app</string>
@@ -12763,10 +12867,6 @@
<string name="network_and_internet_preferences_summary">Connect to public networks</string>
<!-- Search keywords for "Internet" settings [CHAR_LIMIT=NONE] -->
<string name="keywords_internet">network connection, internet, wireless, data, wifi, wi-fi, wi fi, cellular, mobile, cell carrier, 4g, 3g, 2g, lte</string>
- <!-- Label text to view airplane-safe networks. [CHAR LIMIT=40] -->
- <string name="view_airplane_safe_networks">View airplane mode networks</string>
- <!-- Text of message for viewing the networks that are available in airplane mode. [CHAR LIMIT=60] -->
- <string name="viewing_airplane_mode_networks">Viewing airplane mode networks</string>
<!-- Slice title text for turning on the Wi-Fi networks. [CHAR LIMIT=40] -->
<string name="turn_on_wifi">Turn on Wi\u2011Fi</string>
<!-- Title for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
@@ -12779,6 +12879,8 @@
<string name="resetting_internet_text">Resetting your internet\u2026</string>
<!-- Menu option for data connectivity recovery for all requested technologies. [CHAR_LIMIT=NONE] -->
<string name="fix_connectivity">Fix connectivity</string>
+ <!-- Summary for networks available (includes no network connected). [CHAR_LIMIT=NONE] -->
+ <string name="networks_available">Networks available</string>
<!-- Summary for warning to disconnect ethernet first then switch to other networks. [CHAR LIMIT=60] -->
<string name="to_switch_networks_disconnect_ethernet">To switch networks, disconnect ethernet</string>
<!-- Panel subtitle for Wi-Fi turned on. [CHAR LIMIT=60] -->
@@ -12791,6 +12893,9 @@
Summary indicating that a SIM has an active mobile data connection [CHAR LIMIT=50] -->
<string name="mobile_data_connection_active">Connected</string>
<!-- Provider Model:
+ Summary indicating that a active SIM and no network available [CHAR LIMIT=50] -->
+ <string name="mobile_data_no_connection">No connection</string>
+ <!-- Provider Model:
Summary indicating that a SIM has no mobile data connection [CHAR LIMIT=50] -->
<string name="mobile_data_off_summary">Internet won\u0027t auto\u2011connect</string>
<!-- Provider Model: Summary indicating that no other networks available [CHAR LIMIT=50] -->
@@ -12824,10 +12929,12 @@
<string name="category_name_brightness">Brightness</string>
<!-- Lock screen category name in Display Settings [CHAR LIMIT=none] -->
<string name="category_name_lock_display">Lock Display</string>
- <!-- Visibility category name in Display Settings [CHAR LIMIT=none] -->
- <string name="category_name_visibility">Visibility</string>
+ <!-- Appearance category name in Display Settings [CHAR LIMIT=none] -->
+ <string name="category_name_appearance">Appearance</string>
<!-- Color category name in Display Settings [CHAR LIMIT=none] -->
<string name="category_name_color">Color</string>
+ <!-- Name of Other display controls category in Display Settings [CHAR LIMIT=none] -->
+ <string name="category_name_display_controls">Other Display Controls</string>
<!-- Others category name [CHAR LIMIT=none] -->
<string name="category_name_others">Others</string>
<!-- General category name [CHAR LIMIT=none] -->
@@ -12905,4 +13012,13 @@
<!-- Label for extra app info settings for a specific app [CHAR LIMIT=40] -->
<string name="extra_app_info_label" translatable="false"></string>
+
+ <!-- Title for toggle controlling whether notifications are shown when an app pastes from clipboard. [CHAR LIMIT=50] -->
+ <string name="show_clip_access_notification">Show clipboard access</string>
+
+ <!-- Summary for toggle controlling whether notifications are shown when an app pastes from clipboard. [CHAR LIMIT=NONE] -->
+ <string name="show_clip_access_notification_summary">Show a message when apps access text, images, or other content you\u2019ve copied</string>
+
+ <!-- All apps screen title, entry name on Apps page for the user to go to the all apps page. [CHAR LIMIT=30] -->
+ <string name="all_apps">All apps</string>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0d773f1..8ca72db 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -310,6 +310,7 @@
<style name="TextAppearance.SearchBar"
parent="@*android:style/TextAppearance.DeviceDefault.Widget.Toolbar.Subtitle">
<item name="android:textSize">@dimen/search_bar_text_size</item>
+ <item name="android:textColor">?android:attr/textColorTertiary</item>
<item name="android:singleLine">true</item>
</style>
@@ -418,7 +419,6 @@
</style>
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
-
<style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button"/>
<style name="LockPatternContainerStyle">
@@ -481,11 +481,8 @@
</style>
<style name="SearchBarStyle">
- <item name="android:layout_marginEnd">@dimen/search_bar_margin</item>
- <item name="cardCornerRadius">34dp</item>
- <item name="enforceMaterialTheme">true</item>
- <item name="cardElevation">3dp</item>
- <item name="shapeAppearance">@null</item>
+ <item name="cardCornerRadius">@dimen/search_bar_corner_radius</item>
+ <item name="cardElevation">0dp</item>
</style>
<style name="ConditionCardBorderlessButton"
@@ -789,13 +786,11 @@
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
</style>
- <style name="ContextualSuggestionText"
- parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
- <item name="android:autoSizeTextType">uniform</item>
- <item name="android:autoSizeMaxTextSize">@dimen/tool_bar_max_text_size</item>
- <item name="android:autoSizeMinTextSize">@dimen/tool_bar_min_text_size</item>
- <item name="android:maxLines">3</item>
- <item name="android:gravity">bottom</item>
+ <style name="HomepageTitleText" parent="ToolbarText">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_marginBottom">@dimen/homepage_title_margin_bottom</item>
+ <item name="android:layout_marginHorizontal">@dimen/homepage_title_margin_horizontal</item>
</style>
<style name="RequestManageCredentialsButtonPanel">
@@ -883,16 +878,7 @@
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
- <style name="ToolbarText.Collapsed"
- parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
- </style>
-
- <style name="ToolbarText"
- parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
- <item name="android:textSize">@dimen/tool_bar_max_text_size</item>
- </style>
-
- <style name="ToolbarText.MoreThanTwoLines">
- <item name="android:textSize">@dimen/tool_bar_min_text_size</item>
- </style>
+ <style name="ToolbarText.Collapsed" parent="CollapsingToolbarTitle.Collapsed"/>
+ <style name="ToolbarText" parent="CollapsingToolbarTitle"/>
+ <style name="ToolbarText.MoreThanTwoLines" parent="CollapsingToolbarTitle.MoreThanTwoLines"/>
</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index bed02c8..d7b3257 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -23,10 +23,7 @@
<item name="android:windowIsFloating">true</item>
</style>
- <style name="Theme.SettingsBase" parent="@android:style/Theme.DeviceDefault.Settings" />
-
<style name="Theme.Settings" parent="Theme.SettingsBase">
- <item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="android:clipToPadding">false</item>
<item name="android:clipChildren">false</item>
<item name="android:listPreferredItemHeight">72dip</item>
diff --git a/res/xml/accounts_dashboard_settings.xml b/res/xml/accounts_dashboard_settings.xml
index d2affc7..c8627e7 100644
--- a/res/xml/accounts_dashboard_settings.xml
+++ b/res/xml/accounts_dashboard_settings.xml
@@ -22,14 +22,38 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
+ android:key="passwords_category"
+ android:order="10"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
+ settings:keywords="@string/autofill_keywords" />
+
+ <PreferenceCategory
+ android:key="default_service_category"
+ android:order="20"
+ android:title="@string/autofill_app">
+
+ <com.android.settings.widget.GearPreference
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ android:key="default_autofill_main"
+ android:title="@string/autofill_app"
+ settings:keywords="@string/autofill_keywords">
+ <extra
+ android:name="for_work"
+ android:value="false" />
+ </com.android.settings.widget.GearPreference>
+ </PreferenceCategory>
+
+ <PreferenceCategory
android:key="dashboard_tile_placeholder"
- android:order="30"/>
+ android:order="130"/>
<SwitchPreference
android:key="auto_sync_account_data"
android:title="@string/auto_sync_account_title"
android:summary="@string/auto_sync_account_summary"
- android:order="102"
+ android:order="202"
settings:allowDividerAbove="true"/>
<SwitchPreference
@@ -37,12 +61,12 @@
android:title="@string/account_settings_menu_auto_sync_work"
android:summary="@string/auto_sync_account_summary"
settings:forWork="true"
- android:order="103"/>
+ android:order="203"/>
<SwitchPreference
android:key="auto_sync_personal_account_data"
android:title="@string/account_settings_menu_auto_sync_personal"
android:summary="@string/auto_sync_account_summary"
- android:order="104"/>
+ android:order="204"/>
</PreferenceScreen>
diff --git a/res/xml/accounts_personal_dashboard_settings.xml b/res/xml/accounts_personal_dashboard_settings.xml
index db57e3d..3d88cf9 100644
--- a/res/xml/accounts_personal_dashboard_settings.xml
+++ b/res/xml/accounts_personal_dashboard_settings.xml
@@ -23,20 +23,50 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="30"/>
+ android:key="passwords_category"
+ android:order="10"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
+ settings:keywords="@string/autofill_keywords" />
- <SwitchPreference
- android:key="auto_sync_account_data"
- android:title="@string/auto_sync_account_title"
- android:summary="@string/auto_sync_account_summary"
+ <PreferenceCategory
+ android:key="default_service_category"
+ android:order="20"
+ android:title="@string/autofill_app">
+
+ <com.android.settings.widget.GearPreference
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ android:key="default_autofill_main"
+ android:title="@string/autofill_app"
+ settings:keywords="@string/autofill_keywords">
+ <extra
+ android:name="for_work"
+ android:value="false" />
+ </com.android.settings.widget.GearPreference>
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="accounts_category"
android:order="100"
- settings:allowDividerAbove="true"/>
+ android:title="@string/account_settings">
- <SwitchPreference
- android:key="auto_sync_personal_account_data"
- android:title="@string/account_settings_menu_auto_sync_personal"
- android:summary="@string/auto_sync_account_summary"
- android:order="110"/>
+ <PreferenceCategory
+ android:key="dashboard_tile_placeholder"
+ android:order="130"/>
+
+ <SwitchPreference
+ android:key="auto_sync_account_data"
+ android:title="@string/auto_sync_account_title"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="200"
+ settings:allowDividerAbove="true"/>
+
+ <SwitchPreference
+ android:key="auto_sync_personal_account_data"
+ android:title="@string/account_settings_menu_auto_sync_personal"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="210"/>
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/accounts_work_dashboard_settings.xml b/res/xml/accounts_work_dashboard_settings.xml
index b27357d..29e71e2 100644
--- a/res/xml/accounts_work_dashboard_settings.xml
+++ b/res/xml/accounts_work_dashboard_settings.xml
@@ -23,20 +23,50 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="30"/>
+ android:key="passwords_category"
+ android:order="10"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
+ settings:keywords="@string/autofill_keywords" />
- <SwitchPreference
- android:key="auto_sync_account_data"
- android:title="@string/auto_sync_account_title"
- android:summary="@string/auto_sync_account_summary"
+ <com.android.settings.widget.WorkOnlyCategory
+ android:key="autofill_work_app_defaults"
+ android:order="30"
+ android:title="@string/default_for_work">
+
+ <com.android.settings.widget.GearPreference
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ android:key="default_autofill_work"
+ android:title="@string/autofill_app"
+ settings:searchable="false">
+ <extra
+ android:name="for_work"
+ android:value="true" />
+ </com.android.settings.widget.GearPreference>
+ </com.android.settings.widget.WorkOnlyCategory>
+
+ <PreferenceCategory
+ android:key="accounts_category"
android:order="100"
- settings:allowDividerAbove="true"/>
+ android:title="@string/account_settings">
- <SwitchPreference
- android:key="auto_sync_work_account_data"
- android:title="@string/account_settings_menu_auto_sync_work"
- android:summary="@string/auto_sync_account_summary"
- android:order="110"/>
+ <PreferenceCategory
+ android:key="dashboard_tile_placeholder"
+ android:order="130"/>
+
+ <SwitchPreference
+ android:key="auto_sync_account_data"
+ android:title="@string/auto_sync_account_title"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="200"
+ settings:allowDividerAbove="true"/>
+
+ <SwitchPreference
+ android:key="auto_sync_work_account_data"
+ android:title="@string/account_settings_menu_auto_sync_work"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="210"/>
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/apps.xml b/res/xml/apps.xml
index cefb67a..68b5c9a 100644
--- a/res/xml/apps.xml
+++ b/res/xml/apps.xml
@@ -23,7 +23,7 @@
<Preference
android:key="all_app_infos"
- android:title="@string/applications_settings"
+ android:title="@string/all_apps"
android:summary="@string/summary_placeholder"
android:order="-999"
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
diff --git a/res/xml/default_autofill_picker_settings.xml b/res/xml/default_autofill_picker_settings.xml
deleted file mode 100644
index 392f733..0000000
--- a/res/xml/default_autofill_picker_settings.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="default_autofill_picker"
- android:title="@string/autofill_app"
- settings:keywords="@string/autofill_keywords">
-
- <PreferenceCategory
- android:key="passwords_category"
- android:persistent="false"
- android:title="@string/autofill_passwords"
- settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController" >
- </PreferenceCategory>
-
- <PreferenceCategory
- android:key="default_service_category"
- android:title="@string/autofill_app">
-
- <!-- TODO(b/169455298): Fix the redundant title. -->
- <com.android.settings.widget.GearPreference
- android:key="default_autofill_main"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- settings:searchable="false"
- settings:keywords="@string/autofill_keywords">
- <extra android:name="for_work" android:value="false" />
- </com.android.settings.widget.GearPreference>
- </PreferenceCategory>
-
-
- <com.android.settings.widget.WorkOnlyCategory
- android:key="autofill_work_app_defaults"
- android:title="@string/default_for_work">
-
- <com.android.settings.widget.GearPreference
- android:key="default_autofill_work"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- settings:searchable="false"
- settings:keywords="@string/autofill_keywords">
- <extra android:name="for_work" android:value="true" />
- </com.android.settings.widget.GearPreference>
- </com.android.settings.widget.WorkOnlyCategory>
-</PreferenceScreen>
diff --git a/res/xml/display_settings_v2.xml b/res/xml/display_settings_v2.xml
index 0b43914..50879da 100644
--- a/res/xml/display_settings_v2.xml
+++ b/res/xml/display_settings_v2.xml
@@ -59,7 +59,7 @@
</PreferenceCategory>
<PreferenceCategory
- android:title="@string/category_name_visibility">
+ android:title="@string/category_name_appearance">
<com.android.settings.display.darkmode.DarkModePreference
android:key="dark_ui_mode"
@@ -102,7 +102,7 @@
</PreferenceCategory>
<PreferenceCategory
- android:title="@string/category_name_general">
+ android:title="@string/category_name_display_controls">
<SwitchPreference
android:key="auto_rotate"
diff --git a/res/xml/financed_privacy_settings.xml b/res/xml/financed_privacy_settings.xml
new file mode 100644
index 0000000..742d7e1
--- /dev/null
+++ b/res/xml/financed_privacy_settings.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/financed_privacy_settings">
+
+ <PreferenceCategory android:key="exposure_category"
+ android:order="200"
+ android:title="@string/financed_privacy_exposure_category"
+ android:contentDescription="@string/financed_privacy_exposure_category">
+ <Preference android:key="enterprise_privacy_enterprise_data"
+ android:order="210"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_data"
+ android:selectable="false"/>
+ <Preference android:key="enterprise_privacy_installed_packages"
+ android:order="220"
+ android:title="@string/enterprise_privacy_installed_packages"
+ android:selectable="false"/>
+ <Preference android:key="enterprise_privacy_usage_stats"
+ android:order="230"
+ android:title="@string/enterprise_privacy_usage_stats"
+ android:selectable="false"/>
+ <Preference android:key="network_logs"
+ android:order="240"
+ android:title="@string/enterprise_privacy_network_logs"
+ android:selectable="false"/>
+ <Preference android:key="bug_reports"
+ android:order="250"
+ android:title="@string/enterprise_privacy_bug_reports"
+ android:selectable="false"/>
+ <Preference android:key="security_logs"
+ android:order="260"
+ android:title="@string/enterprise_privacy_security_logs"
+ android:selectable="false"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory android:title="@string/financed_privacy_exposure_changes_category"
+ android:order="300"
+ android:key="exposure_changes_category">
+ <Preference android:fragment="com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages"
+ android:order="310"
+ android:key="number_enterprise_installed_packages"
+ android:title="@string/enterprise_privacy_enterprise_installed_packages"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory android:key="device_access_category"
+ android:order="500"
+ android:title="@string/enterprise_privacy_device_access_category">
+ <Preference android:key="enterprise_privacy_lock_device"
+ android:order="510"
+ android:title="@string/financed_privacy_lock_device"
+ android:selectable="false"/>
+ <Preference android:key="enterprise_privacy_wipe_device"
+ android:order="520"
+ android:title="@string/financed_privacy_wipe_device"
+ android:selectable="false"/>
+ <Preference android:key="failed_password_wipe_current_user"
+ android:order="530"
+ android:title="@string/financed_privacy_failed_password_wipe_device"
+ android:selectable="false"/>
+ </PreferenceCategory>
+
+ <com.android.settingslib.widget.FooterPreference
+ android:key="financed_privacy_footer"
+ android:title="@string/financed_privacy_header"
+ android:selectable="false"
+ settings:searchable="false"/>
+</PreferenceScreen>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index 50968d9..d7b8364 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -54,12 +54,6 @@
android:persistent="false"
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings" />
- <Preference
- android:key="default_autofill"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.AutofillPicker"
- settings:keywords="@string/autofill_keywords" />
-
<!-- User dictionary preference title and fragment will be set programmatically. -->
<Preference
android:key="key_user_dictionary_settings"
diff --git a/res/xml/media_management_apps.xml b/res/xml/media_management_apps.xml
new file mode 100644
index 0000000..7cf0d77
--- /dev/null
+++ b/res/xml/media_management_apps.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/media_management_apps_title">
+
+ <com.android.settings.widget.FilterTouchesSwitchPreference
+ android:key="media_management_apps_toggle"
+ android:title="@string/media_management_apps_toggle_label" />
+
+ <com.android.settingslib.widget.FooterPreference
+ android:key="media_management_apps_description"
+ android:title="@string/media_management_apps_description"
+ android:selectable="false" />
+
+</PreferenceScreen>
diff --git a/res/xml/network_provider_internet.xml b/res/xml/network_provider_internet.xml
index bb7117d..4c760aa 100644
--- a/res/xml/network_provider_internet.xml
+++ b/res/xml/network_provider_internet.xml
@@ -98,7 +98,7 @@
android:order="10"
android:fragment="com.android.settings.datausage.DataSaverSummary"/>
- <com.android.settingslib.RestrictedPreference
+ <com.android.settings.vpn2.VpnInfoPreference
android:fragment="com.android.settings.vpn2.VpnSettings"
android:key="vpn_settings"
android:title="@string/vpn_settings_title"
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index 75bbca0..8c6fe41 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -40,32 +40,30 @@
android:title="@string/summary_placeholder"
settings:controller="com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController" />
- <PreferenceCategory>
- <SwitchPreference
- android:key="battery_percentage"
- android:title="@string/battery_percentage"
- android:summary="@string/battery_percentage_description"
- settings:controller="com.android.settings.display.BatteryPercentagePreferenceController" />
- </PreferenceCategory>
+ <Preference
+ android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
+ android:key="battery_saver_summary"
+ android:title="@string/battery_saver"
+ app:iconSpaceReserved="false"
+ settings:controller="com.android.settings.fuelgauge.BatterySaverController" />
- <PreferenceCategory>
- <Preference
- android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
- android:key="battery_saver_summary"
- android:title="@string/battery_saver"
- settings:controller="com.android.settings.fuelgauge.BatterySaverController" />
+ <Preference
+ android:fragment="com.android.settings.fuelgauge.SmartBatterySettings"
+ android:key="smart_battery_manager"
+ android:title="@string/smart_battery_manager_title"
+ app:iconSpaceReserved="false"
+ settings:controller="com.android.settings.fuelgauge.batterytip.BatteryManagerPreferenceController" />
- <Preference
- android:fragment="com.android.settings.fuelgauge.SmartBatterySettings"
- android:key="smart_battery_manager"
- android:title="@string/smart_battery_manager_title"
- settings:controller="com.android.settings.fuelgauge.batterytip.BatteryManagerPreferenceController" />
- </PreferenceCategory>
+ <SwitchPreference
+ android:key="battery_percentage"
+ android:title="@string/battery_percentage"
+ android:summary="@string/battery_percentage_description"
+ app:iconSpaceReserved="false"
+ settings:controller="com.android.settings.display.BatteryPercentagePreferenceController" />
<com.android.settingslib.widget.FooterPreference
android:key="power_usage_footer"
android:title="@string/battery_footer_summary"
android:selectable="false"
- settings:searchable="false"
- settings:allowDividerAbove="true" />
+ settings:searchable="false" />
</PreferenceScreen>
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index f79da61..bd6a954 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -116,4 +116,11 @@
settings:controller="com.android.settings.privacy.EnableContentCaptureWithServiceSettingsPreferenceController">
</com.android.settings.widget.PrimarySwitchPreference>
+ <!-- Clipboard access notifications -->
+ <SwitchPreference
+ android:key="show_clip_access_notification"
+ android:title="@string/show_clip_access_notification"
+ android:summary="@string/show_clip_access_notification_summary"
+ settings:controller="com.android.settings.privacy.ShowClipAccessNotificationPreferenceController"/>
+
</PreferenceScreen>
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index 671d882..83c23b5 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -61,6 +61,16 @@
settings:controller="com.android.settings.applications.specialaccess.zenaccess.ZenAccessController" />
<Preference
+ android:key="media_management_apps"
+ android:title="@string/media_management_apps_title"
+ android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
+ settings:keywords="@string/keywords_media_management_apps">
+ <extra
+ android:name="classname"
+ android:value="com.android.settings.Settings$MediaManagementAppsActivity" />
+ </Preference>
+
+ <Preference
android:key="write_settings_apps"
android:title="@string/write_settings"
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index bc58d7e..b49228e 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -19,11 +19,22 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/storage_settings"
android:orderingFromXml="false">
- <com.android.settings.deviceinfo.storage.StorageSummaryDonutPreference
- android:key="storage_summary"
- android:order="0"
+ <com.android.settingslib.widget.SettingsSpinnerPreference
+ android:key="storage_spinner"
+ android:order="-2"
settings:searchable="false"
- settings:controller="com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController"/>
+ settings:controller="com.android.settings.deviceinfo.storage.StorageSelectionPreferenceController"/>
+ <com.android.settingslib.widget.UsageProgressBarPreference
+ android:key="storage_summary"
+ android:order="-1"
+ settings:searchable="false"
+ settings:controller="com.android.settings.deviceinfo.storage.StorageUsageProgressBarPreferenceController"/>
+ <Preference
+ android:key="free_up_space"
+ android:order="0"
+ android:title="@string/storage_free_up_space_title"
+ android:summary="@string/storage_free_up_space_summary"
+ settings:allowDividerAbove="true"/>
<com.android.settings.widget.PrimarySwitchPreference
android:fragment="com.android.settings.deletionhelper.AutomaticStorageManagerSettings"
android:key="toggle_asm"
@@ -74,4 +85,4 @@
android:key="pref_secondary_users"
android:title="@string/storage_other_users"
android:order="200" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/swipe_bottom_to_notification_settings.xml b/res/xml/swipe_bottom_to_notification_settings.xml
index bec774b..2a75c14 100644
--- a/res/xml/swipe_bottom_to_notification_settings.xml
+++ b/res/xml/swipe_bottom_to_notification_settings.xml
@@ -20,11 +20,13 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/swipe_bottom_to_notifications_title">
- <com.android.settings.widget.VideoPreference
- android:title="@string/swipe_bottom_to_notifications_title"
- settings:animation="@raw/gesture_fingerprint_swipe"
- settings:preview="@drawable/gesture_fingerprint_swipe"
- settings:controller="com.android.settings.widget.VideoPreferenceController"/>
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="one_handed_header"
+ android:layout="@layout/one_handed_header"
+ android:persistent="false"
+ android:selectable="false"
+ settings:allowDividerBelow="false"
+ settings:searchable="false"/>
<SwitchPreference
android:key="gesture_swipe_bottom_to_notification"
diff --git a/res/xml/top_level_settings_grouped.xml b/res/xml/top_level_settings_grouped.xml
index 2c93f3d..704a106 100644
--- a/res/xml/top_level_settings_grouped.xml
+++ b/res/xml/top_level_settings_grouped.xml
@@ -24,7 +24,7 @@
android:fragment="com.android.settings.network.NetworkDashboardFragment"
android:icon="@drawable/ic_homepage_network_v2"
android:key="top_level_network"
- android:order="-140"
+ android:order="-150"
android:title="@string/network_dashboard_title"
settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/>
@@ -32,7 +32,7 @@
android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
android:icon="@drawable/ic_homepage_connected_device_v2"
android:key="top_level_connected_devices"
- android:order="-130"
+ android:order="-140"
android:title="@string/connected_devices_dashboard_title"
settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>
@@ -40,21 +40,21 @@
android:fragment="com.android.settings.applications.AppDashboardFragment"
android:icon="@drawable/ic_homepage_apps_v2"
android:key="top_level_apps"
- android:order="-120"
+ android:order="-130"
android:title="@string/apps_dashboard_title"/>
<com.android.settings.homepage.HomepagePreference
android:fragment="com.android.settings.notification.ConfigureNotificationSettings"
android:icon="@drawable/ic_homepage_notification_v2"
android:key="top_level_notification"
- android:order="-110"
+ android:order="-120"
android:title="@string/configure_notification_settings"/>
<com.android.settings.homepage.HomepagePreference
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
android:icon="@drawable/ic_homepage_battery_v2"
android:key="top_level_battery"
- android:order="-100"
+ android:order="-110"
android:title="@string/power_usage_summary_title"
settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/>
@@ -62,7 +62,7 @@
android:fragment="com.android.settings.deviceinfo.StorageSettings"
android:icon="@drawable/ic_homepage_storage_v2"
android:key="top_level_storage"
- android:order="-90"
+ android:order="-100"
android:title="@string/storage_settings"
settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
@@ -70,21 +70,21 @@
android:fragment="com.android.settings.notification.SoundSettings"
android:icon="@drawable/ic_homepage_sound_v2"
android:key="top_level_sound"
- android:order="-80"
+ android:order="-90"
android:title="@string/sound_settings"/>
<com.android.settings.homepage.HomepagePreference
android:fragment="com.android.settings.DisplaySettings"
android:icon="@drawable/ic_homepage_display_v2"
android:key="top_level_display"
- android:order="-70"
+ android:order="-80"
android:title="@string/display_settings"
settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
<com.android.settings.homepage.RestrictedHomepagePreference
android:icon="@drawable/ic_homepage_wallpaper_v2"
android:key="top_level_wallpaper"
- android:order="-60"
+ android:order="-70"
android:title="@string/wallpaper_settings_title"
settings:controller="com.android.settings.display.TopLevelWallpaperPreferenceController"/>
@@ -92,11 +92,19 @@
android:fragment="com.android.settings.accessibility.AccessibilitySettings"
android:icon="@drawable/ic_homepage_accessibility_v2"
android:key="top_level_accessibility"
- android:order="-50"
+ android:order="-60"
android:title="@string/accessibility_settings"
settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
<com.android.settings.homepage.HomepagePreference
+ android:fragment="com.android.settings.security.SecuritySettings"
+ android:icon="@drawable/ic_homepage_security_v2"
+ android:key="top_level_security"
+ android:order="-50"
+ android:title="@string/security_settings_title"
+ settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
+
+ <com.android.settings.homepage.HomepagePreference
android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"
android:icon="@drawable/ic_homepage_privacy_v2"
android:key="top_level_privacy"
@@ -112,18 +120,10 @@
settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
<com.android.settings.homepage.HomepagePreference
- android:fragment="com.android.settings.security.SecuritySettings"
- android:icon="@drawable/ic_homepage_security_v2"
- android:key="top_level_security"
- android:order="-20"
- android:title="@string/security_settings_title"
- settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
-
- <com.android.settings.homepage.HomepagePreference
android:key="top_level_emergency"
android:title="@string/emergency_settings_preference_title"
android:icon="@drawable/ic_homepage_emergency_v2"
- android:order="-10"
+ android:order="-20"
android:fragment="com.android.settings.emergency.EmergencyDashboardFragment"/>
<com.android.settings.homepage.HomepagePreference
diff --git a/src/com/android/settings/AirplaneModeEnabler.java b/src/com/android/settings/AirplaneModeEnabler.java
index 8b29d67..735ae23 100644
--- a/src/com/android/settings/AirplaneModeEnabler.java
+++ b/src/com/android/settings/AirplaneModeEnabler.java
@@ -24,7 +24,6 @@
import android.provider.Settings;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionInfo;
-import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -62,7 +61,7 @@
private TelephonyManager mTelephonyManager;
@VisibleForTesting
- AirplaneModeTelephonyCallback mTelephonyCallback;
+ PhoneStateListener mPhoneStateListener;
public AirplaneModeEnabler(Context context, OnAirplaneModeChangedListener listener) {
super(context, Settings.Global.AIRPLANE_MODE_ON);
@@ -72,18 +71,16 @@
mOnAirplaneModeChangedListener = listener;
mTelephonyManager = context.getSystemService(TelephonyManager.class);
- mTelephonyCallback = new AirplaneModeTelephonyCallback();
- }
- class AirplaneModeTelephonyCallback extends TelephonyCallback implements
- TelephonyCallback.RadioPowerStateListener {
- @Override
- public void onRadioPowerStateChanged(int state) {
- if (DEBUG) {
- Log.d(LOG_TAG, "RadioPower: " + state);
+ mPhoneStateListener = new PhoneStateListener(Looper.getMainLooper()) {
+ @Override
+ public void onRadioPowerStateChanged(int state) {
+ if (DEBUG) {
+ Log.d(LOG_TAG, "RadioPower: " + state);
+ }
+ onAirplaneModeChanged();
}
- onAirplaneModeChanged();
- }
+ };
}
/**
@@ -101,14 +98,16 @@
* Start listening to the phone state change
*/
public void start() {
- mTelephonyManager.registerTelephonyCallback(mContext.getMainExecutor(), mTelephonyCallback);
+ mTelephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED);
}
/**
* Stop listening to the phone state change
*/
public void stop() {
- mTelephonyManager.unregisterTelephonyCallback(mTelephonyCallback);
+ mTelephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_NONE);
}
private void setAirplaneModeOn(boolean enabling) {
@@ -193,3 +192,4 @@
return WirelessUtils.isAirplaneModeOn(mContext);
}
}
+
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index cf43827..95e68de 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -217,6 +217,8 @@
public static class OverlaySettingsActivity extends SettingsActivity { /* empty */ }
public static class ManageExternalStorageActivity extends SettingsActivity { /* empty */ }
public static class AppManageExternalStorageActivity extends SettingsActivity { /* empty */ }
+ public static class MediaManagementAppsActivity extends SettingsActivity { /* empty */ }
+ public static class AppMediaManagementAppsActivity extends SettingsActivity { /* empty */ }
public static class WriteSettingsActivity extends SettingsActivity { /* empty */ }
public static class ChangeWifiStateActivity extends SettingsActivity { /* empty */ }
public static class AppDrawOverlaySettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index 0c1ace9..a276ad7 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -446,6 +446,13 @@
}
/**
+ * Returns the specified system service from the owning Activity.
+ */
+ protected <T> T getSystemService(final Class<T> serviceClass) {
+ return getActivity().getSystemService(serviceClass);
+ }
+
+ /**
* Returns the PackageManager from the owning Activity.
*/
protected PackageManager getPackageManager() {
diff --git a/src/com/android/settings/UserCredentialsSettings.java b/src/com/android/settings/UserCredentialsSettings.java
index 5f72ca5..80b97e4 100644
--- a/src/com/android/settings/UserCredentialsSettings.java
+++ b/src/com/android/settings/UserCredentialsSettings.java
@@ -34,7 +34,6 @@
import android.security.IKeyChainService;
import android.security.KeyChain;
import android.security.KeyChain.KeyChainConnection;
-import android.security.keystore.AndroidKeyStoreProvider;
import android.security.keystore.KeyProperties;
import android.security.keystore2.AndroidKeyStoreLoadStoreParameter;
import android.util.Log;
@@ -74,6 +73,8 @@
implements View.OnClickListener {
private static final String TAG = "UserCredentialsSettings";
+ private static final String KEYSTORE_PROVIDER = "AndroidKeyStore";
+
@Override
public int getMetricsCategory() {
return SettingsEnums.USER_CREDENTIALS;
@@ -210,15 +211,10 @@
private void deleteWifiCredential(final Credential credential) {
try {
- KeyStore keyStore = null;
- if (AndroidKeyStoreProvider.isKeystore2Enabled()) {
- keyStore = KeyStore.getInstance("AndroidKeyStore");
- keyStore.load(
- new AndroidKeyStoreLoadStoreParameter(
- KeyProperties.NAMESPACE_WIFI));
- } else {
- keyStore = AndroidKeyStoreProvider.getKeyStoreForUid(Process.WIFI_UID);
- }
+ final KeyStore keyStore = KeyStore.getInstance(KEYSTORE_PROVIDER);
+ keyStore.load(
+ new AndroidKeyStoreLoadStoreParameter(
+ KeyProperties.NAMESPACE_WIFI));
keyStore.deleteEntry(credential.getAlias());
} catch (Exception e) {
throw new RuntimeException("Failed to delete keys from keystore.");
@@ -278,18 +274,13 @@
final int wifiUid = UserHandle.getUid(myUserId, Process.WIFI_UID);
try {
- KeyStore processKeystore = KeyStore.getInstance("AndroidKeyStore");
+ KeyStore processKeystore = KeyStore.getInstance(KEYSTORE_PROVIDER);
processKeystore.load(null);
KeyStore wifiKeystore = null;
if (myUserId == 0) {
- // Only the primary user may see wifi configurations.
- if (AndroidKeyStoreProvider.isKeystore2Enabled()) {
- wifiKeystore = KeyStore.getInstance("AndroidKeyStore");
- wifiKeystore.load(new AndroidKeyStoreLoadStoreParameter(
- KeyProperties.NAMESPACE_WIFI));
- } else {
- wifiKeystore = AndroidKeyStoreProvider.getKeyStoreForUid(Process.WIFI_UID);
- }
+ wifiKeystore = KeyStore.getInstance(KEYSTORE_PROVIDER);
+ wifiKeystore.load(new AndroidKeyStoreLoadStoreParameter(
+ KeyProperties.NAMESPACE_WIFI));
}
List<Credential> credentials = new ArrayList<>();
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 4bf97cc..391ee90 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -54,6 +54,7 @@
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.net.ConnectivityManager;
+import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.Network;
import android.net.wifi.WifiManager;
@@ -111,7 +112,6 @@
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.widget.ActionBarShadowController;
-import java.net.InetAddress;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -246,13 +246,13 @@
private static String formatIpAddresses(LinkProperties prop) {
if (prop == null) return null;
- final Iterator<InetAddress> iter = prop.getAllAddresses().iterator();
+ final Iterator<LinkAddress> iter = prop.getAllLinkAddresses().iterator();
// If there are no entries, return null
if (!iter.hasNext()) return null;
// Concatenate all available addresses, comma separated
String addresses = "";
while (iter.hasNext()) {
- addresses += iter.next().getHostAddress();
+ addresses += iter.next().getAddress().getHostAddress();
if (iter.hasNext()) addresses += "\n";
}
return addresses;
diff --git a/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java b/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
index 6b31988..5d2a3fa 100644
--- a/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
+++ b/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
@@ -16,6 +16,8 @@
package com.android.settings.accessibility;
+import static com.android.settings.accessibility.ItemInfoArrayAdapter.ItemInfo;
+
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -29,15 +31,20 @@
import android.text.style.ImageSpan;
import android.view.LayoutInflater;
import android.view.View;
+import android.widget.AbsListView;
+import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.IntDef;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
@@ -47,6 +54,8 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.List;
+
/**
* Utility class for creating the edit dialog.
@@ -61,15 +70,13 @@
@IntDef({
DialogType.EDIT_SHORTCUT_GENERIC,
DialogType.EDIT_SHORTCUT_MAGNIFICATION,
- DialogType.EDIT_MAGNIFICATION_MODE,
DialogType.EDIT_MAGNIFICATION_SWITCH_SHORTCUT,
})
private @interface DialogType {
int EDIT_SHORTCUT_GENERIC = 0;
int EDIT_SHORTCUT_MAGNIFICATION = 1;
- int EDIT_MAGNIFICATION_MODE = 2;
- int EDIT_MAGNIFICATION_SWITCH_SHORTCUT = 3;
+ int EDIT_MAGNIFICATION_SWITCH_SHORTCUT = 2;
}
/**
@@ -107,23 +114,6 @@
}
/**
- * Method to show the magnification mode dialog in Magnification.
- *
- * @param context A valid context
- * @param dialogTitle The title of magnify mode dialog
- * @param listener The listener to determine the action of magnify mode dialog
- * @return A magnification mode dialog in Magnification
- */
- public static AlertDialog showMagnificationModeDialog(Context context,
- CharSequence dialogTitle, DialogInterface.OnClickListener listener) {
- final AlertDialog alertDialog = createDialog(context,
- DialogType.EDIT_MAGNIFICATION_MODE, dialogTitle, listener);
- alertDialog.show();
- setScrollIndicators(alertDialog);
- return alertDialog;
- }
-
- /**
* Method to show the magnification edit shortcut dialog in Magnification.
*
* @param context A valid context
@@ -163,11 +153,21 @@
*/
private static void setScrollIndicators(AlertDialog dialog) {
final ScrollView scrollView = dialog.findViewById(R.id.container_layout);
- scrollView.setScrollIndicators(
+ setScrollIndicators(scrollView);
+ }
+
+ /**
+ * Sets the scroll indicators for dialog view. The indicators appear while content view is
+ * out of vision for vertical scrolling.
+ *
+ * @param view The view contains customized dialog content. Usually it is {@link ScrollView} or
+ * {@link AbsListView}
+ */
+ private static void setScrollIndicators(@NonNull View view) {
+ view.setScrollIndicators(
View.SCROLL_INDICATOR_TOP | View.SCROLL_INDICATOR_BOTTOM,
View.SCROLL_INDICATOR_TOP | View.SCROLL_INDICATOR_BOTTOM);
}
-
private static void setEditShortcutButtonsListener(AlertDialog dialog,
View.OnClickListener listener) {
final View contentView = dialog.findViewById(R.id.container_layout);
@@ -212,12 +212,6 @@
initMagnifyShortcut(context, contentView);
initAdvancedWidget(contentView);
break;
- case DialogType.EDIT_MAGNIFICATION_MODE:
- contentView = inflater.inflate(
- R.layout.accessibility_edit_magnification_mode, null);
- initMagnifyFullScreen(context, contentView);
- initMagnifyWindowScreen(context, contentView);
- break;
case DialogType.EDIT_MAGNIFICATION_SWITCH_SHORTCUT:
contentView = inflater.inflate(
R.layout.accessibility_edit_magnification_shortcut, null);
@@ -229,25 +223,6 @@
return contentView;
}
- private static void initMagnifyFullScreen(Context context, View view) {
- final View dialogView = view.findViewById(R.id.magnify_full_screen);
- final CharSequence title = context.getText(
- R.string.accessibility_magnification_area_settings_full_screen);
- setupShortcutWidget(dialogView, title, R.drawable.accessibility_magnification_full_screen);
- }
-
- private static void initMagnifyWindowScreen(Context context, View view) {
- final View dialogView = view.findViewById(R.id.magnify_window_screen);
- final CharSequence title = context.getText(
- R.string.accessibility_magnification_area_settings_window_screen);
- setupShortcutWidget(dialogView, title,
- R.drawable.accessibility_magnification_window_screen);
- }
-
- private static void setupShortcutWidget(View view, CharSequence titleText, int imageResId) {
- setupShortcutWidget(view, titleText, null, imageResId);
- }
-
private static void setupShortcutWidget(View view, CharSequence titleText,
CharSequence summaryText, int imageResId) {
final CheckBox checkBox = view.findViewById(R.id.checkbox);
@@ -345,7 +320,6 @@
spannableMessage.setSpan(
imageSpan, indexIconStart, indexIconEnd,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-
return spannableMessage;
}
@@ -368,4 +342,52 @@
typedArray.recycle();
return colorResId;
}
+
+ /**
+ * Creates a dialog with the given view.
+ *
+ * @param context A valid context
+ * @param dialogTitle The title of the dialog
+ * @param customView The customized view
+ * @param listener This listener will be invoked when the positive button in the dialog is
+ * clicked
+ * @return the {@link Dialog} with the given view
+ */
+ public static Dialog createCustomDialog(Context context, CharSequence dialogTitle,
+ View customView, DialogInterface.OnClickListener listener) {
+ final AlertDialog alertDialog = new AlertDialog.Builder(context)
+ .setView(customView)
+ .setTitle(dialogTitle)
+ .setCancelable(true)
+ .setPositiveButton(R.string.save, listener)
+ .setNegativeButton(R.string.cancel, null)
+ .create();
+ if (customView instanceof ScrollView || customView instanceof AbsListView) {
+ setScrollIndicators(customView);
+ }
+ return alertDialog;
+ }
+
+ /**
+ * Creates a single choice {@link ListView} with given {@link ItemInfo} list.
+ *
+ * @param context A context.
+ * @param itemInfoList A {@link ItemInfo} list.
+ * @param itemListener The listener will be invoked when the item is clicked.
+ */
+ @NonNull
+ public static ListView createSingleChoiceListView(@NonNull Context context,
+ @NonNull List<? extends ItemInfo> itemInfoList,
+ @Nullable AdapterView.OnItemClickListener itemListener) {
+ final ListView list = new ListView(context);
+ // Set an id to save its state.
+ list.setId(android.R.id.list);
+ list.setDivider(/* divider= */ null);
+ list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
+ final ItemInfoArrayAdapter
+ adapter = new ItemInfoArrayAdapter(context, itemInfoList);
+ list.setAdapter(adapter);
+ list.setOnItemClickListener(itemListener);
+ return list;
+ }
}
diff --git a/src/com/android/settings/accessibility/ItemInfoArrayAdapter.java b/src/com/android/settings/accessibility/ItemInfoArrayAdapter.java
new file mode 100644
index 0000000..edb16a2
--- /dev/null
+++ b/src/com/android/settings/accessibility/ItemInfoArrayAdapter.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.DrawableRes;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.settings.R;
+
+import java.util.List;
+
+/**
+ * An {@link ArrayAdapter} to fill the information of {@link ItemInfo} in the item view. The item
+ * view must have textview to set the title.
+ *
+ * @param <T> the type of elements in the array, inherited from {@link ItemInfo}.
+ */
+public class ItemInfoArrayAdapter<T extends ItemInfoArrayAdapter.ItemInfo> extends ArrayAdapter<T> {
+
+ public ItemInfoArrayAdapter(@NonNull Context context, @NonNull List<T> items) {
+ super(context, R.layout.dialog_single_radio_choice_list_item, R.id.title, items);
+ }
+
+ @NonNull
+ @Override
+ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+ final View root = super.getView(position, convertView, parent);
+
+ final ItemInfo item = getItem(position);
+ final TextView title = root.findViewById(R.id.title);
+ title.setText(item.mTitle);
+ final TextView summary = root.findViewById(R.id.summary);
+ if (!TextUtils.isEmpty(item.mSummary)) {
+ summary.setVisibility(View.VISIBLE);
+ summary.setText(item.mSummary);
+ } else {
+ summary.setVisibility(View.GONE);
+ }
+ final ImageView image = root.findViewById(R.id.image);
+ image.setImageResource(item.mDrawableId);
+ return root;
+ }
+
+ /**
+ * Presents a data structure shown in the item view.
+ */
+ public static class ItemInfo {
+ @NonNull
+ public final CharSequence mTitle;
+ @Nullable
+ public final CharSequence mSummary;
+ @DrawableRes
+ public final int mDrawableId;
+
+ public ItemInfo(@NonNull CharSequence title, @Nullable CharSequence summary,
+ @DrawableRes int drawableId) {
+ mTitle = title;
+ mSummary = summary;
+ mDrawableId = drawableId;
+ }
+ }
+}
diff --git a/src/com/android/settings/accessibility/MagnificationSettingsFragment.java b/src/com/android/settings/accessibility/MagnificationSettingsFragment.java
index 6003a6d..c4d6fd5 100644
--- a/src/com/android/settings/accessibility/MagnificationSettingsFragment.java
+++ b/src/com/android/settings/accessibility/MagnificationSettingsFragment.java
@@ -26,20 +26,26 @@
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
+import android.util.Log;
+import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.CheckBox;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
+import com.android.settings.accessibility.MagnificationCapabilities.MagnificationMode;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
+import java.util.ArrayList;
+import java.util.List;
import java.util.StringJoiner;
/** Settings page for magnification. */
@@ -52,6 +58,7 @@
static final int DIALOG_MAGNIFICATION_CAPABILITY = 1;
@VisibleForTesting
static final int DIALOG_MAGNIFICATION_SWITCH_SHORTCUT = 2;
+
@VisibleForTesting
static final String EXTRA_CAPABILITY = "capability";
private static final int NONE = 0;
@@ -60,13 +67,13 @@
private Preference mModePreference;
@VisibleForTesting
Dialog mDialog;
- @VisibleForTesting
- CheckBox mMagnifyFullScreenCheckBox;
- @VisibleForTesting
- CheckBox mMagnifyWindowCheckBox;
+ @VisibleForTesting
+ ListView mMagnificationModesListView;
private int mCapabilities = NONE;
+ private final List<MagnificationModeInfo> mModeInfos = new ArrayList<>();
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -77,6 +84,7 @@
if (mCapabilities == NONE) {
mCapabilities = MagnificationCapabilities.getCapabilities(getPrefContext());
}
+ initModeInfos();
}
@Override
@@ -121,13 +129,10 @@
@Override
public Dialog onCreateDialog(int dialogId) {
final CharSequence title;
+
switch (dialogId) {
case DIALOG_MAGNIFICATION_CAPABILITY:
- title = getPrefContext().getString(
- R.string.accessibility_magnification_mode_title);
- mDialog = AccessibilityEditDialogUtils.showMagnificationModeDialog(getPrefContext(),
- title, this::callOnAlertDialogCheckboxClicked);
- initializeDialogCheckBox(mDialog);
+ mDialog = createMagnificationModeDialog();
return mDialog;
case DIALOG_MAGNIFICATION_SWITCH_SHORTCUT:
title = getPrefContext().getString(
@@ -136,10 +141,97 @@
getPrefContext(), title, this::onSwitchShortcutDialogPositiveButtonClicked);
return mDialog;
}
-
throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
}
+ private Dialog createMagnificationModeDialog() {
+ mMagnificationModesListView = AccessibilityEditDialogUtils.createSingleChoiceListView(
+ getPrefContext(), mModeInfos, this::onMagnificationModeSelected);
+
+ final View headerView = LayoutInflater.from(getPrefContext()).inflate(
+ R.layout.accessibility_magnification_mode_header, mMagnificationModesListView,
+ false);
+ mMagnificationModesListView.addHeaderView(headerView, null, /* isSelectable= */false);
+
+ mMagnificationModesListView.setItemChecked(computeSelectedMagnificationModeIndex(), true);
+ final CharSequence title = getPrefContext().getString(
+ R.string.accessibility_magnification_mode_dialog_title);
+
+ return AccessibilityEditDialogUtils.createCustomDialog(getPrefContext(), title,
+ mMagnificationModesListView, this::onMagnificationModeDialogPositiveButtonClicked);
+ }
+
+ private int computeSelectedMagnificationModeIndex() {
+ final int size = mModeInfos.size();
+ for (int i = 0; i < size; i++) {
+ if (mModeInfos.get(i).mMagnificationMode == mCapabilities) {
+ return i + mMagnificationModesListView.getHeaderViewsCount();
+ }
+ }
+ Log.w(TAG, "chosen mode" + mCapabilities + "is not in the list");
+ return 0;
+ }
+
+ private void onMagnificationModeSelected(AdapterView<?> parent, View view, int position,
+ long id) {
+ final MagnificationModeInfo modeInfo =
+ (MagnificationModeInfo) mMagnificationModesListView.getItemAtPosition(position);
+ if (modeInfo.mMagnificationMode == mCapabilities) {
+ return;
+ }
+ mCapabilities = modeInfo.mMagnificationMode;
+ if (isTripleTapEnabled() && mCapabilities != MagnificationMode.FULLSCREEN) {
+ showDialog(DIALOG_MAGNIFICATION_SWITCH_SHORTCUT);
+ }
+ }
+
+ private void onMagnificationModeDialogPositiveButtonClicked(DialogInterface dialogInterface,
+ int which) {
+ final int selectedIndex = mMagnificationModesListView.getCheckedItemPosition();
+ if (selectedIndex != AdapterView.INVALID_POSITION) {
+ final MagnificationModeInfo modeInfo =
+ (MagnificationModeInfo) mMagnificationModesListView.getItemAtPosition(
+ selectedIndex);
+ updateCapabilities(modeInfo.mMagnificationMode);
+ } else {
+ Log.w(TAG, "no checked item in the list");
+ }
+ }
+
+ private void updateCapabilities(int mode) {
+ mCapabilities = mode;
+ MagnificationCapabilities.setCapabilities(getPrefContext(), mCapabilities);
+ mModePreference.setSummary(
+ MagnificationCapabilities.getSummary(getPrefContext(), mCapabilities));
+ }
+
+ private void initModeInfos() {
+ mModeInfos.clear();
+ mModeInfos.add(new MagnificationModeInfo(getPrefContext().getText(
+ R.string.accessibility_magnification_mode_dialog_option_full_screen), null,
+ R.drawable.accessibility_magnification_full_screen, MagnificationMode.FULLSCREEN));
+ mModeInfos.add(new MagnificationModeInfo(getPrefContext().getText(
+ R.string.accessibility_magnification_mode_dialog_option_window), null,
+ R.drawable.accessibility_magnification_window_screen, MagnificationMode.WINDOW));
+ mModeInfos.add(new MagnificationModeInfo(getPrefContext().getText(
+ R.string.accessibility_magnification_mode_dialog_option_switch),
+ getPrefContext().getText(
+ R.string.accessibility_magnification_area_settings_mode_switch_summary),
+ R.drawable.accessibility_magnification_switch, MagnificationMode.ALL));
+ }
+
+ @VisibleForTesting
+ static class MagnificationModeInfo extends ItemInfoArrayAdapter.ItemInfo {
+ @MagnificationMode
+ public final int mMagnificationMode;
+
+ MagnificationModeInfo(@NonNull CharSequence title, @Nullable CharSequence summary,
+ @DrawableRes int drawableId, @MagnificationMode int magnificationMode) {
+ super(title, summary, drawableId);
+ mMagnificationMode = magnificationMode;
+ }
+ }
+
private void initModePreference() {
mModePreference = findPreference(PREF_KEY_MODE);
mModePreference.setOnPreferenceClickListener(preference -> {
@@ -149,12 +241,6 @@
});
}
- private void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
- updateCapabilities(true);
- mModePreference.setSummary(
- MagnificationCapabilities.getSummary(getPrefContext(), mCapabilities));
- }
-
private void onSwitchShortcutDialogPositiveButtonClicked(View view) {
//TODO(b/147990389): Merge this function into util until magnification change format to
// Component.
@@ -188,95 +274,6 @@
joiner.toString());
}
- private void initializeDialogCheckBox(Dialog dialog) {
- final View dialogFullScreenView = dialog.findViewById(R.id.magnify_full_screen);
- final View dialogFullScreenTextArea = dialogFullScreenView.findViewById(R.id.container);
- mMagnifyFullScreenCheckBox = dialogFullScreenView.findViewById(R.id.checkbox);
-
- final View dialogWidowView = dialog.findViewById(R.id.magnify_window_screen);
- final View dialogWindowTextArea = dialogWidowView.findViewById(R.id.container);
- mMagnifyWindowCheckBox = dialogWidowView.findViewById(R.id.checkbox);
-
- updateAlertDialogCheckState();
- updateAlertDialogEnableState(dialogFullScreenTextArea, dialogWindowTextArea);
-
- setTextAreasClickListener(dialogFullScreenTextArea, mMagnifyFullScreenCheckBox,
- dialogWindowTextArea, mMagnifyWindowCheckBox);
- }
-
- private void setTextAreasClickListener(View fullScreenTextArea, CheckBox fullScreenCheckBox,
- View windowTextArea, CheckBox windowCheckBox) {
- fullScreenTextArea.setOnClickListener(v -> {
- fullScreenCheckBox.toggle();
- updateCapabilities(false);
- updateAlertDialogEnableState(fullScreenTextArea, windowTextArea);
- });
-
- windowTextArea.setOnClickListener(v -> {
- windowCheckBox.toggle();
- updateCapabilities(false);
- updateAlertDialogEnableState(fullScreenTextArea, windowTextArea);
-
- if (isTripleTapEnabled() && windowCheckBox.isChecked()) {
- showDialog(DIALOG_MAGNIFICATION_SWITCH_SHORTCUT);
- }
- });
- }
-
- private void updateAlertDialogCheckState() {
- updateCheckStatus(mMagnifyWindowCheckBox,
- Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW);
- updateCheckStatus(mMagnifyFullScreenCheckBox,
- Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN);
-
- }
-
- private void updateCheckStatus(CheckBox checkBox, int mode) {
- checkBox.setChecked((mode & mCapabilities) != 0);
- }
-
- private void updateAlertDialogEnableState(View fullScreenTextArea, View windowTextArea) {
- switch (mCapabilities) {
- case Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN:
- setViewAndChildrenEnabled(fullScreenTextArea, false);
- break;
- case Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW:
- setViewAndChildrenEnabled(windowTextArea, false);
- break;
- case Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL:
- setViewAndChildrenEnabled(fullScreenTextArea, true);
- setViewAndChildrenEnabled(windowTextArea, true);
- break;
- default:
- throw new IllegalArgumentException(
- "Unsupported ACCESSIBILITY_MAGNIFICATION_CAPABILITY " + mCapabilities);
- }
- }
-
- private void setViewAndChildrenEnabled(View view, boolean enabled) {
- view.setEnabled(enabled);
- if (view instanceof ViewGroup) {
- final ViewGroup viewGroup = (ViewGroup) view;
- for (int i = 0; i < viewGroup.getChildCount(); i++) {
- View child = viewGroup.getChildAt(i);
- setViewAndChildrenEnabled(child, enabled);
- }
- }
- }
-
- private void updateCapabilities(boolean saveToDB) {
- int capabilities = 0;
- capabilities |=
- mMagnifyFullScreenCheckBox.isChecked()
- ? Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN : 0;
- capabilities |= mMagnifyWindowCheckBox.isChecked()
- ? Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW : 0;
- mCapabilities = capabilities;
- if (saveToDB) {
- MagnificationCapabilities.setCapabilities(getPrefContext(), mCapabilities);
- }
- }
-
private boolean isTripleTapEnabled() {
return Settings.Secure.getInt(getPrefContext().getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF) == ON;
diff --git a/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java b/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java
index 82b3a64..bfe61b7 100644
--- a/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java
+++ b/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java
@@ -18,8 +18,8 @@
import android.content.Context;
import android.hardware.display.ColorDisplayManager;
-import android.provider.Settings;
+import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
/** PreferenceController that shows the Reduce Bright Colors summary */
@@ -32,8 +32,8 @@
@Override
public CharSequence getSummary() {
- return AccessibilityUtil.getSummary(mContext,
- Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED);
+ return mContext.getText(
+ R.string.reduce_bright_colors_preference_summary);
}
@Override
diff --git a/src/com/android/settings/accessibility/ShortcutPreference.java b/src/com/android/settings/accessibility/ShortcutPreference.java
index a9b542a..cff9117 100644
--- a/src/com/android/settings/accessibility/ShortcutPreference.java
+++ b/src/com/android/settings/accessibility/ShortcutPreference.java
@@ -63,7 +63,7 @@
super(context, attrs);
setLayoutResource(R.layout.accessibility_shortcut_secondary_action);
setWidgetLayoutResource(R.layout.preference_widget_primary_switch);
- setIconSpaceReserved(true);
+ setIconSpaceReserved(false);
}
@Override
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index cf9c08b..be6b141 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -488,7 +488,7 @@
// Show the "Settings" menu as if it were a preference screen.
mSettingsPreference = new Preference(getPrefContext());
mSettingsPreference.setTitle(mSettingsTitle);
- mSettingsPreference.setIconSpaceReserved(true);
+ mSettingsPreference.setIconSpaceReserved(false);
mSettingsPreference.setIntent(mSettingsIntent);
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
diff --git a/src/com/android/settings/accessibility/TurnScreenDarkerFragment.java b/src/com/android/settings/accessibility/TurnScreenDarkerFragment.java
index ad4bd56..0e0a600 100644
--- a/src/com/android/settings/accessibility/TurnScreenDarkerFragment.java
+++ b/src/com/android/settings/accessibility/TurnScreenDarkerFragment.java
@@ -94,8 +94,6 @@
if (ColorDisplayManager.isColorTransformAccelerated(getContext())) {
mToggleInversionPreference.setSummary(AccessibilityUtil.getSummary(
getContext(), Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED));
- mReduceBrightColorsPreference.setSummary(AccessibilityUtil.getSummary(
- getContext(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED));
getPreferenceScreen().removePreference(experimentalCategory);
} else {
// Move following preferences to experimental category if device don't supports HWC
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 7b50b46..9e232f4 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -27,6 +27,8 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
+import com.android.settings.applications.defaultapps.DefaultWorkAutofillPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -68,14 +70,22 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- return buildPreferenceControllers(context, this /* parent */, authorities);
+ buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
+ return controllers;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- SettingsPreferenceFragment parent, String[] authorities) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ static void buildAutofillPreferenceControllers(
+ Context context, List<AbstractPreferenceController> controllers) {
+ controllers.add(new DefaultAutofillPreferenceController(context));
+ controllers.add(new DefaultWorkAutofillPreferenceController(context));
+ }
+ private static void buildAccountPreferenceControllers(
+ Context context, SettingsPreferenceFragment parent, String[] authorities,
+ List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.ALL);
@@ -86,7 +96,6 @@
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
- return controllers;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
@@ -95,8 +104,11 @@
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
- return buildPreferenceControllers(
- context, null /* parent */, null /* authorities*/);
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAccountPreferenceControllers(
+ context, null /* parent */, null /* authorities*/, controllers);
+ buildAutofillPreferenceControllers(context, controllers);
+ return controllers;
}
@Override
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
index f29326e..c97c886 100644
--- a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -18,6 +18,8 @@
import static android.provider.Settings.EXTRA_AUTHORITIES;
+import static com.android.settings.accounts.AccountDashboardFragment.buildAutofillPreferenceControllers;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -61,14 +63,16 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- return buildPreferenceControllers(context, this /* parent */, authorities);
+ buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
+ return controllers;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- SettingsPreferenceFragment parent, String[] authorities) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
-
+ private static void buildAccountPreferenceControllers(
+ Context context, SettingsPreferenceFragment parent, String[] authorities,
+ List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.PERSONAL);
@@ -78,7 +82,6 @@
controllers.add(accountPrefController);
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
- return controllers;
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
@@ -88,6 +91,7 @@
// @Override
// public List<AbstractPreferenceController> createPreferenceControllers(
// Context context) {
+// ..Add autofill here too..
// return buildPreferenceControllers(
// context, null /* parent */, null /* authorities*/);
// }
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index ff5bc78..64c2d13 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -75,11 +75,12 @@
private static final String TAG = "AccountPrefController";
- private static final int ORDER_ACCOUNT_PROFILES = 1;
+ private static final int ORDER_ACCOUNT_PROFILES = 101;
private static final int ORDER_LAST = 1002;
private static final int ORDER_NEXT_TO_LAST = 1001;
private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
+ private static final String PREF_KEY_ACCOUNTS = "accounts_category";
private static final String PREF_KEY_ADD_ACCOUNT = "add_account";
private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
@@ -348,8 +349,10 @@
}
}
final PreferenceScreen screen = mFragment.getPreferenceScreen();
- if (screen != null) {
- screen.addPreference(preferenceGroup);
+ final PreferenceGroup accounts =
+ screen == null ? null : screen.findPreference(PREF_KEY_ACCOUNTS);
+ if (accounts != null) {
+ accounts.addPreference(preferenceGroup);
}
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
index 853c66b..4e6515b 100644
--- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -18,6 +18,8 @@
import static android.provider.Settings.EXTRA_AUTHORITIES;
+import static com.android.settings.accounts.AccountDashboardFragment.buildAutofillPreferenceControllers;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -61,14 +63,16 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- return buildPreferenceControllers(context, this /* parent */, authorities);
+ buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
+ return controllers;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- SettingsPreferenceFragment parent, String[] authorities) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
-
+ private static void buildAccountPreferenceControllers(
+ Context context, SettingsPreferenceFragment parent, String[] authorities,
+ List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.WORK);
@@ -78,7 +82,6 @@
controllers.add(accountPrefController);
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
- return controllers;
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
@@ -88,6 +91,7 @@
// @Override
// public List<AbstractPreferenceController> createPreferenceControllers(
// Context context) {
+// ..Add autofill here too..
// return buildPreferenceControllers(
// context, null /* parent */, null /* authorities*/);
// }
diff --git a/src/com/android/settings/accounts/AvatarViewMixin.java b/src/com/android/settings/accounts/AvatarViewMixin.java
index 7eb8cab..c4ab55a 100644
--- a/src/com/android/settings/accounts/AvatarViewMixin.java
+++ b/src/com/android/settings/accounts/AvatarViewMixin.java
@@ -17,7 +17,6 @@
package com.android.settings.accounts;
import android.accounts.Account;
-import android.app.ActivityManager;
import android.app.settings.SettingsEnums;
import android.content.ContentResolver;
import android.content.Context;
@@ -65,14 +64,23 @@
private final Context mContext;
private final ImageView mAvatarView;
private final MutableLiveData<Bitmap> mAvatarImage;
- private final ActivityManager mActivityManager;
@VisibleForTesting
String mAccountName;
+ /**
+ * @return true if the avatar icon is supported.
+ */
+ public static boolean isAvatarSupported(Context context) {
+ if (!context.getResources().getBoolean(R.bool.config_show_avatar_in_homepage)) {
+ Log.d(TAG, "Feature disabled by config. Skipping");
+ return false;
+ }
+ return true;
+ }
+
public AvatarViewMixin(SettingsHomepageActivity activity, ImageView avatarView) {
mContext = activity.getApplicationContext();
- mActivityManager = mContext.getSystemService(ActivityManager.class);
mAvatarView = avatarView;
mAvatarView.setOnClickListener(v -> {
Intent intent;
@@ -117,14 +125,6 @@
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
- if (!mContext.getResources().getBoolean(R.bool.config_show_avatar_in_homepage)) {
- Log.d(TAG, "Feature disabled by config. Skipping");
- return;
- }
- if (mActivityManager.isLowRamDevice()) {
- Log.d(TAG, "Feature disabled on low ram device. Skipping");
- return;
- }
if (hasAccount()) {
loadAccount();
} else {
diff --git a/src/com/android/settings/applications/AppStateMediaManagementAppsBridge.java b/src/com/android/settings/applications/AppStateMediaManagementAppsBridge.java
new file mode 100644
index 0000000..ff2b4d8
--- /dev/null
+++ b/src/com/android/settings/applications/AppStateMediaManagementAppsBridge.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.applications;
+
+import android.Manifest;
+import android.app.AppOpsManager;
+import android.content.Context;
+
+import com.android.settingslib.applications.ApplicationsState;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.applications.ApplicationsState.AppFilter;
+
+import java.util.List;
+
+/**
+ * Retrieves information from {@link AppOpsManager} and {@link android.content.pm.PackageManager}
+ * regarding {@link AppOpsManager#OP_MANAGE_MEDIA} and
+ * {@link Manifest.permission#MANAGE_MEDIA}.
+ */
+public class AppStateMediaManagementAppsBridge extends AppStateAppOpsBridge {
+
+ private final AppOpsManager mAppOpsManager;
+
+ public AppStateMediaManagementAppsBridge(Context context, ApplicationsState appState,
+ Callback callback) {
+ super(context, appState, callback,
+ AppOpsManager.strOpToOp(AppOpsManager.OPSTR_MANAGE_MEDIA),
+ new String[]{Manifest.permission.MANAGE_MEDIA});
+
+ mAppOpsManager = context.getSystemService(AppOpsManager.class);
+ }
+
+ @Override
+ protected void updateExtraInfo(AppEntry app, String pkg, int uid) {
+ app.extraInfo = createPermissionState(pkg, uid);
+ }
+
+ @Override
+ protected void loadAllExtraInfo() {
+ super.loadAllExtraInfo();
+ final List<AppEntry> allApps = mAppSession.getAllApps();
+ final int appCount = allApps.size();
+ for (int i = 0; i < appCount; i++) {
+ final AppEntry appEntry = allApps.get(i);
+ if (appEntry.extraInfo instanceof PermissionState) {
+ updateExtraInfo(appEntry, appEntry.info.packageName, appEntry.info.uid);
+ }
+ }
+ }
+
+ /**
+ * Returns information regarding {@link Manifest.permission#MANAGE_MEDIA} for the given
+ * package and uid.
+ */
+ public PermissionState createPermissionState(String packageName, int uid) {
+ final PermissionState permissionState = getPermissionInfo(packageName, uid);
+ permissionState.appOpMode = mAppOpsManager.unsafeCheckOpNoThrow(
+ AppOpsManager.OPSTR_MANAGE_MEDIA, uid, packageName);
+ return permissionState;
+ }
+
+ /**
+ * Used by {@link com.android.settings.applications.manageapplications.AppFilterRegistry} to
+ * determine which apps get to appear on the Special App Access list.
+ */
+ public static final AppFilter FILTER_MEDIA_MANAGEMENT_APPS = new AppFilter() {
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public boolean filterApp(AppEntry info) {
+ return info.extraInfo != null;
+ }
+ };
+}
diff --git a/src/com/android/settings/applications/HibernatedAppsPreferenceController.java b/src/com/android/settings/applications/HibernatedAppsPreferenceController.java
index 40cbb2e..4088d3a 100644
--- a/src/com/android/settings/applications/HibernatedAppsPreferenceController.java
+++ b/src/com/android/settings/applications/HibernatedAppsPreferenceController.java
@@ -20,15 +20,19 @@
import static com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED;
+import android.apphibernation.AppHibernationManager;
import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
import android.provider.DeviceConfig;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import java.util.List;
+
/**
* A preference controller handling the logic for updating summary of hibernated apps.
- * TODO(b/181172051): add intent to launch Auto Revoke UI in app_and_notification.xml
*/
public final class HibernatedAppsPreferenceController extends BasePreferenceController {
private static final String TAG = "HibernatedAppsPrefController";
@@ -39,7 +43,8 @@
@Override
public int getAvailabilityStatus() {
- return isHibernationEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return isHibernationEnabled() && getNumHibernated() > 0
+ ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
@@ -50,8 +55,27 @@
}
private int getNumHibernated() {
- //TODO(b/181172051): hook into hibernation service to get the number of hibernated apps.
- return 0;
+ final PackageManager pm = mContext.getPackageManager();
+ final AppHibernationManager ahm = mContext.getSystemService(AppHibernationManager.class);
+ final List<String> hibernatedPackages = ahm.getHibernatingPackagesForUser();
+ int numHibernated = hibernatedPackages.size();
+
+ // Also need to count packages that are auto revoked but not hibernated.
+ final List<PackageInfo> packages = pm.getInstalledPackages(
+ PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.GET_PERMISSIONS);
+ for (PackageInfo pi : packages) {
+ final String packageName = pi.packageName;
+ if (!hibernatedPackages.contains(packageName) && pi.requestedPermissions != null) {
+ for (String perm : pi.requestedPermissions) {
+ if ((pm.getPermissionFlags(perm, packageName, mContext.getUser())
+ & PackageManager.FLAG_PERMISSION_AUTO_REVOKED) != 0) {
+ numHibernated++;
+ break;
+ }
+ }
+ }
+ }
+ return numHibernated;
}
private static boolean isHibernationEnabled() {
diff --git a/src/com/android/settings/applications/appinfo/HibernationSwitchPreferenceController.java b/src/com/android/settings/applications/appinfo/HibernationSwitchPreferenceController.java
index 8ab2c9d..40be629 100644
--- a/src/com/android/settings/applications/appinfo/HibernationSwitchPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/HibernationSwitchPreferenceController.java
@@ -80,7 +80,8 @@
/**
* Set the package. And also retrieve details from package manager. Some packages may be
- * exempted from hibernation by default.
+ * exempted from hibernation by default. This method should only be called to initialize the
+ * controller.
* @param packageName The name of the package whose hibernation state to be managed.
*/
void setPackage(@NonNull String packageName) {
@@ -93,8 +94,7 @@
? android.os.Build.VERSION_CODES.R
: android.os.Build.VERSION_CODES.Q;
try {
- mPackageUid = packageManager.getPackageUidAsUser(
- packageName, mContext.getUserId());
+ mPackageUid = packageManager.getPackageUid(packageName, /* flags */ 0);
mIsPackageExemptByDefault = packageManager.getTargetSdkVersion(packageName)
<= maxTargetSdkVersionForExemptApps;
mIsPackageSet = true;
diff --git a/src/com/android/settings/applications/appinfo/MediaManagementAppsDetails.java b/src/com/android/settings/applications/appinfo/MediaManagementAppsDetails.java
new file mode 100644
index 0000000..f60fb4f
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/MediaManagementAppsDetails.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.applications.appinfo;
+
+import android.app.AppOpsManager;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.os.Bundle;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceChangeListener;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.R;
+import com.android.settings.applications.AppInfoWithHeader;
+import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
+import com.android.settings.applications.AppStateMediaManagementAppsBridge;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+
+/**
+ * Class for displaying app info related to {@link AppOpsManager#OP_MANAGE_MEDIA}.
+ */
+public class MediaManagementAppsDetails extends AppInfoWithHeader implements
+ OnPreferenceChangeListener {
+
+ private static final String KEY_SWITCH_PREF = "media_management_apps_toggle";
+
+ private AppStateMediaManagementAppsBridge mAppBridge;
+ private AppOpsManager mAppOpsManager;
+ private SwitchPreference mSwitchPref;
+ private PermissionState mPermissionState;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final Context context = getActivity();
+ mAppBridge = new AppStateMediaManagementAppsBridge(context, mState, null /* callback */);
+ mAppOpsManager = context.getSystemService(AppOpsManager.class);
+
+ // initialize preferences
+ addPreferencesFromResource(R.xml.media_management_apps);
+ mSwitchPref = findPreference(KEY_SWITCH_PREF);
+
+ // install event listeners
+ mSwitchPref.setOnPreferenceChangeListener(this);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean value = (Boolean) newValue;
+ if (preference == mSwitchPref) {
+ if (mPermissionState != null && value != mPermissionState.isPermissible()) {
+ setCanManageMedia(value);
+ logPermissionChange(value, mPackageName);
+ refreshUi();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private void setCanManageMedia(boolean newState) {
+ mAppOpsManager.setUidMode(AppOpsManager.OP_MANAGE_MEDIA, mPackageInfo.applicationInfo.uid,
+ newState ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_ERRORED);
+ }
+
+ private void logPermissionChange(boolean newState, String packageName) {
+ mMetricsFeatureProvider.action(
+ mMetricsFeatureProvider.getAttribution(getActivity()),
+ SettingsEnums.ACTION_MEDIA_MANAGEMENT_APPS_TOGGLE,
+ getMetricsCategory(),
+ packageName,
+ newState ? 1 : 0);
+ }
+
+ @Override
+ protected boolean refreshUi() {
+ if (mPackageInfo == null || mPackageInfo.applicationInfo == null) {
+ return false;
+ }
+
+ mPermissionState = mAppBridge.createPermissionState(mPackageName,
+ mPackageInfo.applicationInfo.uid);
+ mSwitchPref.setEnabled(mPermissionState.permissionDeclared);
+ mSwitchPref.setChecked(mPermissionState.isPermissible());
+ return true;
+ }
+
+ @Override
+ protected AlertDialog createDialog(int id, int errorCode) {
+ return null;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.MEDIA_MANAGEMENT_APPS;
+ }
+
+ /**
+ * Returns the string that states whether the app has access to
+ * {@link android.Manifest.permission#MANAGE_MEDIA}.
+ */
+ public static int getSummary(Context context, AppEntry entry) {
+ final PermissionState state;
+ if (entry.extraInfo instanceof PermissionState) {
+ state = (PermissionState) entry.extraInfo;
+ } else {
+ state = new AppStateMediaManagementAppsBridge(context, null /* appState */,
+ null /* callback */).createPermissionState(entry.info.packageName,
+ entry.info.uid);
+ }
+
+ return state.isPermissible() ? R.string.app_permission_summary_allowed
+ : R.string.app_permission_summary_not_allowed;
+ }
+}
diff --git a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
index f27530e..123adda 100644
--- a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
+++ b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
@@ -16,37 +16,63 @@
package com.android.settings.applications.autofill;
+import static android.service.autofill.AutofillService.EXTRA_RESULT;
+
+import static androidx.lifecycle.Lifecycle.Event.ON_CREATE;
+import static androidx.lifecycle.Lifecycle.Event.ON_DESTROY;
+
import android.annotation.UserIdInt;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.RemoteException;
import android.os.UserHandle;
+import android.service.autofill.AutofillService;
import android.service.autofill.AutofillServiceInfo;
+import android.service.autofill.IAutoFillService;
import android.text.TextUtils;
import android.util.IconDrawableFactory;
+import android.util.Log;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.LifecycleOwner;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.os.IResultReceiver;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
+import java.lang.ref.WeakReference;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* Queries available autofill services and adds preferences for those that declare passwords
* settings.
+ * <p>
+ * The controller binds to each service to fetch the number of saved passwords in each.
*/
-public class PasswordsPreferenceController extends BasePreferenceController {
+public class PasswordsPreferenceController extends BasePreferenceController
+ implements LifecycleObserver {
+ private static final String TAG = "AutofillSettings";
private final PackageManager mPm;
private final IconDrawableFactory mIconFactory;
private final List<AutofillServiceInfo> mServices;
+ private LifecycleOwner mLifecycleOwner;
+
public PasswordsPreferenceController(Context context, String preferenceKey) {
this(context, preferenceKey,
AutofillServiceInfo.getAvailableServices(context, UserHandle.myUserId()));
@@ -67,6 +93,11 @@
mServices = availableServices;
}
+ @OnLifecycleEvent(ON_CREATE)
+ void onCreate(LifecycleOwner lifecycleOwner) {
+ mLifecycleOwner = lifecycleOwner;
+ }
+
@Override
public int getAvailabilityStatus() {
return mServices.isEmpty() ? CONDITIONALLY_UNAVAILABLE : AVAILABLE;
@@ -96,7 +127,79 @@
pref.setIntent(
new Intent(Intent.ACTION_MAIN)
.setClassName(serviceInfo.packageName, service.getPasswordsActivity()));
+
+ final MutableLiveData<Integer> passwordCount = new MutableLiveData<>();
+ passwordCount.observe(
+ // TODO(b/169455298): Validate the result.
+ // TODO(b/169455298): Use a Quantity String resource.
+ mLifecycleOwner, count -> pref.setSummary("" + count + " passwords saved"));
+ // TODO(b/169455298): Limit the number of concurrent queries.
+ // TODO(b/169455298): Cache the results for some time.
+ requestSavedPasswordCount(service, user, passwordCount);
+
group.addPreference(pref);
}
}
+
+ private void requestSavedPasswordCount(
+ AutofillServiceInfo service, @UserIdInt int user, MutableLiveData<Integer> data) {
+ final Intent intent =
+ new Intent(AutofillService.SERVICE_INTERFACE)
+ .setComponent(service.getServiceInfo().getComponentName());
+ final AutofillServiceConnection connection = new AutofillServiceConnection(mContext, data);
+ if (mContext.bindServiceAsUser(
+ intent, connection, Context.BIND_AUTO_CREATE, UserHandle.of(user))) {
+ connection.mBound.set(true);
+ mLifecycleOwner.getLifecycle().addObserver(connection);
+ }
+ }
+
+ private static class AutofillServiceConnection implements ServiceConnection, LifecycleObserver {
+ final WeakReference<Context> mContext;
+ final MutableLiveData<Integer> mData;
+ final AtomicBoolean mBound = new AtomicBoolean();
+
+ AutofillServiceConnection(Context context, MutableLiveData<Integer> data) {
+ mContext = new WeakReference<>(context);
+ mData = data;
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ final IAutoFillService autofillService = IAutoFillService.Stub.asInterface(service);
+ // TODO check if debug is logged on user build.
+ Log.d(TAG, "Fetching password count from " + name);
+ try {
+ autofillService.onSavedPasswordCountRequest(
+ new IResultReceiver.Stub() {
+ @Override
+ public void send(int resultCode, Bundle resultData) {
+ Log.d(TAG, "Received password count result " + resultCode
+ + " from " + name);
+ if (resultCode == 0 && resultData != null) {
+ mData.postValue(resultData.getInt(EXTRA_RESULT));
+ }
+ unbind();
+ }
+ });
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to fetch password count: " + e);
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ }
+
+ @OnLifecycleEvent(ON_DESTROY)
+ void unbind() {
+ if (!mBound.getAndSet(false)) {
+ return;
+ }
+ final Context context = mContext.get();
+ if (context != null) {
+ context.unbindService(this);
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/applications/defaultapps/AutofillPicker.java b/src/com/android/settings/applications/defaultapps/AutofillPicker.java
deleted file mode 100644
index 62a478f..0000000
--- a/src/com/android/settings/applications/defaultapps/AutofillPicker.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.applications.defaultapps;
-
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.Indexable;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.search.SearchIndexable;
-
-import java.util.Arrays;
-import java.util.List;
-
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
-public class AutofillPicker extends DashboardFragment {
- private static final String TAG = "AutofillPicker";
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.DEFAULT_AUTOFILL_PICKER;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.default_autofill_picker_settings;
- }
-
- @Override
- protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context);
- }
-
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.default_autofill_picker_settings) {
-
- @Override
- public List<AbstractPreferenceController> getPreferenceControllers(Context
- context) {
- return buildPreferenceControllers(context);
- }
- };
-
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
- return Arrays.asList(
- new DefaultAutofillPreferenceController(context),
- new DefaultWorkAutofillPreferenceController(context));
- }
-}
diff --git a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
index f4de226..d1d4f62 100644
--- a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
+++ b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
@@ -22,6 +22,7 @@
import com.android.settings.applications.AppStateAlarmsAndRemindersBridge;
import com.android.settings.applications.AppStateInstallAppsBridge;
import com.android.settings.applications.AppStateManageExternalStorageBridge;
+import com.android.settings.applications.AppStateMediaManagementAppsBridge;
import com.android.settings.applications.AppStateNotificationBridge;
import com.android.settings.applications.AppStateOverlayBridge;
import com.android.settings.applications.AppStatePowerBridge;
@@ -52,6 +53,7 @@
FILTER_APPS_INSTALL_SOURCES,
FILTER_APPS_BLOCKED,
FILTER_ALARMS_AND_REMINDERS,
+ FILTER_APPS_MEDIA_MANAGEMENT,
})
@interface FilterType {
}
@@ -76,14 +78,15 @@
public static final int FILTER_APPS_BLOCKED = 16;
public static final int FILTER_MANAGE_EXTERNAL_STORAGE = 17;
public static final int FILTER_ALARMS_AND_REMINDERS = 18;
- // Next id: 18. If you add an entry here, length of mFilters should be updated
+ public static final int FILTER_APPS_MEDIA_MANAGEMENT = 19;
+ // Next id: 20. If you add an entry here, length of mFilters should be updated
private static AppFilterRegistry sRegistry;
private final AppFilterItem[] mFilters;
private AppFilterRegistry() {
- mFilters = new AppFilterItem[19];
+ mFilters = new AppFilterItem[20];
// High power allowlist, on
mFilters[FILTER_APPS_POWER_ALLOWLIST] = new AppFilterItem(
@@ -194,6 +197,12 @@
AppStateAlarmsAndRemindersBridge.FILTER_CLOCK_APPS,
FILTER_ALARMS_AND_REMINDERS,
R.string.alarms_and_reminders_title);
+
+ // Apps that can manage media files
+ mFilters[FILTER_APPS_MEDIA_MANAGEMENT] = new AppFilterItem(
+ AppStateMediaManagementAppsBridge.FILTER_MEDIA_MANAGEMENT_APPS,
+ FILTER_APPS_MEDIA_MANAGEMENT,
+ R.string.media_management_apps_title);
}
public static AppFilterRegistry getInstance() {
@@ -224,6 +233,8 @@
return FILTER_MANAGE_EXTERNAL_STORAGE;
case ManageApplications.LIST_TYPE_ALARMS_AND_REMINDERS:
return FILTER_ALARMS_AND_REMINDERS;
+ case ManageApplications.LIST_TYPE_MEDIA_MANAGEMENT_APPS:
+ return FILTER_APPS_MEDIA_MANAGEMENT;
default:
return FILTER_APPS_ALL;
}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 2dadbbc..a92f539 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -96,6 +96,7 @@
import com.android.settings.applications.AppStateBaseBridge;
import com.android.settings.applications.AppStateInstallAppsBridge;
import com.android.settings.applications.AppStateManageExternalStorageBridge;
+import com.android.settings.applications.AppStateMediaManagementAppsBridge;
import com.android.settings.applications.AppStateNotificationBridge;
import com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState;
import com.android.settings.applications.AppStateOverlayBridge;
@@ -110,6 +111,7 @@
import com.android.settings.applications.appinfo.DrawOverlayDetails;
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
+import com.android.settings.applications.appinfo.MediaManagementAppsDetails;
import com.android.settings.applications.appinfo.WriteSettingsDetails;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.InstrumentedFragment;
@@ -233,6 +235,7 @@
public static final int LIST_TYPE_WIFI_ACCESS = 13;
public static final int LIST_MANAGE_EXTERNAL_STORAGE = 14;
public static final int LIST_TYPE_ALARMS_AND_REMINDERS = 15;
+ public static final int LIST_TYPE_MEDIA_MANAGEMENT_APPS = 16;
// List types that should show instant apps.
public static final Set<Integer> LIST_TYPES_WITH_INSTANT = new ArraySet<>(Arrays.asList(
@@ -274,7 +277,7 @@
Intent intent = activity.getIntent();
Bundle args = getArguments();
int screenTitle = intent.getIntExtra(
- SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.application_info_label);
+ SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.all_apps);
String className = args != null ? args.getString(EXTRA_CLASSNAME) : null;
if (className == null) {
className = intent.getComponent().getClassName();
@@ -324,6 +327,9 @@
} else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) {
mListType = LIST_MANAGE_EXTERNAL_STORAGE;
screenTitle = R.string.manage_external_storage_title;
+ } else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) {
+ mListType = LIST_TYPE_MEDIA_MANAGEMENT_APPS;
+ screenTitle = R.string.media_management_apps_title;
} else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) {
mListType = LIST_TYPE_ALARMS_AND_REMINDERS;
screenTitle = R.string.alarms_and_reminders_title;
@@ -336,7 +342,7 @@
screenTitle = R.string.app_notifications_title;
} else {
if (screenTitle == -1) {
- screenTitle = R.string.application_info_label;
+ screenTitle = R.string.all_apps;
}
mListType = LIST_TYPE_MAIN;
}
@@ -553,6 +559,8 @@
return SettingsEnums.MANAGE_EXTERNAL_STORAGE;
case LIST_TYPE_ALARMS_AND_REMINDERS:
return SettingsEnums.ALARMS_AND_REMINDERS;
+ case LIST_TYPE_MEDIA_MANAGEMENT_APPS:
+ return SettingsEnums.MEDIA_MANAGEMENT_APPS;
default:
return SettingsEnums.PAGE_UNKNOWN;
}
@@ -678,6 +686,10 @@
startAppInfoFragment(AlarmsAndRemindersDetails.class,
R.string.alarms_and_reminders_label);
break;
+ case LIST_TYPE_MEDIA_MANAGEMENT_APPS:
+ startAppInfoFragment(MediaManagementAppsDetails.class,
+ R.string.media_management_apps_title);
+ break;
// TODO: Figure out if there is a way where we can spin up the profile's settings
// process ahead of time, to avoid a long load of data when user clicks on a managed
// app. Maybe when they load the list of apps that contains managed profile apps.
@@ -758,6 +770,8 @@
return R.string.help_uri_manage_external_storage;
case LIST_TYPE_ALARMS_AND_REMINDERS:
return R.string.help_uri_alarms_and_reminders;
+ case LIST_TYPE_MEDIA_MANAGEMENT_APPS:
+ return R.string.help_uri_media_management_apps;
default:
case LIST_TYPE_MAIN:
return R.string.help_uri_apps;
@@ -1082,6 +1096,8 @@
mExtraInfoBridge = new AppStateManageExternalStorageBridge(mContext, mState, this);
} else if (mManageApplications.mListType == LIST_TYPE_ALARMS_AND_REMINDERS) {
mExtraInfoBridge = new AppStateAlarmsAndRemindersBridge(mContext, mState, this);
+ } else if (mManageApplications.mListType == LIST_TYPE_MEDIA_MANAGEMENT_APPS) {
+ mExtraInfoBridge = new AppStateMediaManagementAppsBridge(mContext, mState, this);
} else {
mExtraInfoBridge = null;
}
@@ -1546,6 +1562,9 @@
case LIST_TYPE_ALARMS_AND_REMINDERS:
holder.setSummary(AlarmsAndRemindersDetails.getSummary(mContext, entry));
break;
+ case LIST_TYPE_MEDIA_MANAGEMENT_APPS:
+ holder.setSummary(MediaManagementAppsDetails.getSummary(mContext, entry));
+ break;
default:
holder.updateSizeText(entry, mManageApplications.mInvalidSizeStr, mWhichSize);
break;
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index 096c2c5..bc5aa47 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -192,6 +192,7 @@
updateSubLayout(mLayoutPreference.findViewById(R.id.layout_middle),
BluetoothDevice.METADATA_MAIN_ICON,
BluetoothDevice.METADATA_MAIN_BATTERY,
+ BluetoothDevice.METADATA_MAIN_LOW_BATTERY_THRESHOLD,
BluetoothDevice.METADATA_MAIN_CHARGING,
/* titleResId */ 0,
MAIN_DEVICE_ID);
@@ -202,6 +203,7 @@
updateSubLayout(mLayoutPreference.findViewById(R.id.layout_left),
BluetoothDevice.METADATA_UNTETHERED_LEFT_ICON,
BluetoothDevice.METADATA_UNTETHERED_LEFT_BATTERY,
+ BluetoothDevice.METADATA_UNTETHERED_LEFT_LOW_BATTERY_THRESHOLD,
BluetoothDevice.METADATA_UNTETHERED_LEFT_CHARGING,
R.string.bluetooth_left_name,
LEFT_DEVICE_ID);
@@ -209,6 +211,7 @@
updateSubLayout(mLayoutPreference.findViewById(R.id.layout_middle),
BluetoothDevice.METADATA_UNTETHERED_CASE_ICON,
BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY,
+ BluetoothDevice.METADATA_UNTETHERED_CASE_LOW_BATTERY_THRESHOLD,
BluetoothDevice.METADATA_UNTETHERED_CASE_CHARGING,
R.string.bluetooth_middle_name,
CASE_DEVICE_ID);
@@ -216,6 +219,7 @@
updateSubLayout(mLayoutPreference.findViewById(R.id.layout_right),
BluetoothDevice.METADATA_UNTETHERED_RIGHT_ICON,
BluetoothDevice.METADATA_UNTETHERED_RIGHT_BATTERY,
+ BluetoothDevice.METADATA_UNTETHERED_RIGHT_LOW_BATTERY_THRESHOLD,
BluetoothDevice.METADATA_UNTETHERED_RIGHT_CHARGING,
R.string.bluetooth_right_name,
RIGHT_DEVICE_ID);
@@ -243,7 +247,7 @@
}
private void updateSubLayout(LinearLayout linearLayout, int iconMetaKey, int batteryMetaKey,
- int chargeMetaKey, int titleResId, int deviceId) {
+ int lowBatteryMetaKey, int chargeMetaKey, int titleResId, int deviceId) {
if (linearLayout == null) {
return;
}
@@ -273,7 +277,15 @@
linearLayout.setVisibility(View.VISIBLE);
batterySummaryView.setText(com.android.settings.Utils.formatPercentage(batteryLevel));
batterySummaryView.setVisibility(View.VISIBLE);
- showBatteryIcon(linearLayout, batteryLevel, charging, batteryMetaKey);
+ int lowBatteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, lowBatteryMetaKey);
+ if (lowBatteryLevel == BluetoothUtils.META_INT_ERROR) {
+ if (batteryMetaKey == BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY) {
+ lowBatteryLevel = CASE_LOW_BATTERY_LEVEL;
+ } else {
+ lowBatteryLevel = LOW_BATTERY_LEVEL;
+ }
+ }
+ showBatteryIcon(linearLayout, batteryLevel, lowBatteryLevel, charging);
} else {
if (deviceId == MAIN_DEVICE_ID) {
linearLayout.setVisibility(View.VISIBLE);
@@ -354,11 +366,8 @@
});
}
- private void showBatteryIcon(LinearLayout linearLayout, int level, boolean charging,
- int batteryMetaKey) {
- final int lowBatteryLevel =
- batteryMetaKey == BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY
- ? CASE_LOW_BATTERY_LEVEL : LOW_BATTERY_LEVEL;
+ private void showBatteryIcon(LinearLayout linearLayout, int level, int lowBatteryLevel,
+ boolean charging) {
final boolean enableLowBattery = level <= lowBatteryLevel && !charging;
final ImageView imageView = linearLayout.findViewById(R.id.bt_battery_icon);
if (enableLowBattery) {
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 5e51284..c08c149 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -45,6 +45,7 @@
import com.android.settings.applications.appinfo.DrawOverlayDetails;
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
+import com.android.settings.applications.appinfo.MediaManagementAppsDetails;
import com.android.settings.applications.appinfo.WriteSettingsDetails;
import com.android.settings.applications.appops.BackgroundCheckSummary;
import com.android.settings.applications.assist.ManageAssist;
@@ -318,6 +319,7 @@
MediaControlsSettings.class.getName(),
NetworkProviderSettings.class.getName(),
AlarmsAndRemindersDetails.class.getName(),
+ MediaManagementAppsDetails.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/datausage/ChartDataUsagePreference.java b/src/com/android/settings/datausage/ChartDataUsagePreference.java
index 6c845a9..0577e9c 100644
--- a/src/com/android/settings/datausage/ChartDataUsagePreference.java
+++ b/src/com/android/settings/datausage/ChartDataUsagePreference.java
@@ -174,8 +174,8 @@
@VisibleForTesting
List<DataUsageSummaryNode> getDensedStatsData(List<NetworkCycleData> usageSummary) {
final List<DataUsageSummaryNode> dataUsageSummaryNodes = new ArrayList<>();
- final long overallDataUsage = usageSummary.stream()
- .mapToLong(NetworkCycleData::getTotalUsage).sum();
+ final long overallDataUsage = Math.max(1L, usageSummary.stream()
+ .mapToLong(NetworkCycleData::getTotalUsage).sum());
long cumulatedDataUsage = 0L;
int cumulatedDataUsagePercentage = 0;
diff --git a/src/com/android/settings/development/AdbIpAddressPreferenceController.java b/src/com/android/settings/development/AdbIpAddressPreferenceController.java
index 45fe51b..ce5a851 100644
--- a/src/com/android/settings/development/AdbIpAddressPreferenceController.java
+++ b/src/com/android/settings/development/AdbIpAddressPreferenceController.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.debug.IAdbManager;
import android.net.ConnectivityManager;
+import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.wifi.WifiManager;
import android.os.RemoteException;
@@ -135,7 +136,7 @@
return null;
}
- Iterator<InetAddress> iter = prop.getAllAddresses().iterator();
+ Iterator<LinkAddress> iter = prop.getAllLinkAddresses().iterator();
// If there are no entries, return null
if (!iter.hasNext()) {
return null;
@@ -144,7 +145,7 @@
// Concatenate all available addresses, newline separated
StringBuilder addresses = new StringBuilder();
while (iter.hasNext()) {
- InetAddress addr = iter.next();
+ InetAddress addr = iter.next().getAddress();
if (addr instanceof Inet4Address) {
// adb only supports ipv4 at the moment
addresses.append(addr.getHostAddress());
diff --git a/src/com/android/settings/development/DefaultUsbConfigurationPreferenceController.java b/src/com/android/settings/development/DefaultUsbConfigurationPreferenceController.java
index 905c552..be7704f 100644
--- a/src/com/android/settings/development/DefaultUsbConfigurationPreferenceController.java
+++ b/src/com/android/settings/development/DefaultUsbConfigurationPreferenceController.java
@@ -54,4 +54,11 @@
mPreference.setDisabledByAdmin(
checkIfUsbDataSignalingIsDisabled(mContext, UserHandle.myUserId()));
}
+
+ @Override
+ protected void onDeveloperOptionsSwitchEnabled() {
+ super.onDeveloperOptionsSwitchEnabled();
+ mPreference.setDisabledByAdmin(
+ checkIfUsbDataSignalingIsDisabled(mContext, UserHandle.myUserId()));
+ }
}
diff --git a/src/com/android/settings/development/UsbAudioRoutingPreferenceController.java b/src/com/android/settings/development/UsbAudioRoutingPreferenceController.java
index 8aa4f3c..e130b2b 100644
--- a/src/com/android/settings/development/UsbAudioRoutingPreferenceController.java
+++ b/src/com/android/settings/development/UsbAudioRoutingPreferenceController.java
@@ -83,4 +83,11 @@
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
}
+
+ @Override
+ protected void onDeveloperOptionsSwitchEnabled() {
+ super.onDeveloperOptionsSwitchEnabled();
+ mPreference.setDisabledByAdmin(
+ checkIfUsbDataSignalingIsDisabled(mContext, UserHandle.myUserId()));
+ }
}
diff --git a/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java b/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
index e6d9dfd..536f699 100644
--- a/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
+++ b/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
@@ -58,7 +58,7 @@
public DeviceNamePreferenceController(Context context, String key) {
super(context, key);
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ mWifiManager = context.getSystemService(WifiManager.class);
mWifiDeviceNameTextValidator = new WifiDeviceNameTextValidator();
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuController.java b/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuController.java
deleted file mode 100644
index 00a79a0..0000000
--- a/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuController.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.deviceinfo;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.storage.VolumeInfo;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-
-import com.android.settings.R;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
-import com.android.settingslib.core.lifecycle.events.OnOptionsItemSelected;
-import com.android.settingslib.core.lifecycle.events.OnPrepareOptionsMenu;
-
-import java.util.Objects;
-
-/**
- * Handles the option menu on the Storage settings.
- */
-public class PrivateVolumeOptionMenuController implements LifecycleObserver, OnCreateOptionsMenu,
- OnPrepareOptionsMenu, OnOptionsItemSelected {
- private static final int OPTIONS_MENU_MIGRATE_DATA = 100;
-
- private Context mContext;
- private VolumeInfo mVolumeInfo;
- private PackageManager mPm;
-
- public PrivateVolumeOptionMenuController(
- Context context, VolumeInfo volumeInfo, PackageManager packageManager) {
- mContext = context;
- mVolumeInfo = volumeInfo;
- mPm = packageManager;
- }
-
- @Override
- public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
- menu.add(Menu.NONE, OPTIONS_MENU_MIGRATE_DATA, 0, R.string.storage_menu_migrate);
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- if (mVolumeInfo == null) {
- return;
- }
-
- // Only offer to migrate when not current storage
- final VolumeInfo privateVol = mPm.getPrimaryStorageCurrentVolume();
- final MenuItem migrate = menu.findItem(OPTIONS_MENU_MIGRATE_DATA);
- if (migrate != null) {
- migrate.setVisible((privateVol != null)
- && (privateVol.getType() == VolumeInfo.TYPE_PRIVATE)
- && !Objects.equals(mVolumeInfo, privateVol)
- && privateVol.isMountedWritable());
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem menuItem) {
- if (menuItem.getItemId() == OPTIONS_MENU_MIGRATE_DATA) {
- final Intent intent = new Intent(mContext, StorageWizardMigrateConfirm.class);
- intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolumeInfo.getId());
- mContext.startActivity(intent);
- return true;
- }
- return false;
- }
-}
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index 10c3a43..b8c4e28 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -20,13 +20,18 @@
import android.app.settings.SettingsEnums;
import android.app.usage.StorageStatsManager;
import android.content.Context;
+import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
+import android.os.storage.DiskInfo;
+import android.os.storage.StorageEventListener;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
+import android.os.storage.VolumeRecord;
import android.provider.SearchIndexableResource;
+import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;
@@ -41,15 +46,22 @@
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.deviceinfo.storage.AutomaticStorageManagementSwitchPreferenceController;
import com.android.settings.deviceinfo.storage.CachedStorageValuesHelper;
+import com.android.settings.deviceinfo.storage.DiskInitFragment;
import com.android.settings.deviceinfo.storage.SecondaryUserController;
import com.android.settings.deviceinfo.storage.StorageAsyncLoader;
+import com.android.settings.deviceinfo.storage.StorageEntry;
import com.android.settings.deviceinfo.storage.StorageItemPreferenceController;
+import com.android.settings.deviceinfo.storage.StorageSelectionPreferenceController;
+import com.android.settings.deviceinfo.storage.StorageUsageProgressBarPreferenceController;
+import com.android.settings.deviceinfo.storage.StorageUtils;
import com.android.settings.deviceinfo.storage.UserIconLoader;
import com.android.settings.deviceinfo.storage.VolumeSizesLoader;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.deviceinfo.PrivateStorageInfo;
import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
import com.android.settingslib.search.SearchIndexable;
@@ -57,48 +69,229 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
@SearchIndexable
public class StorageDashboardFragment extends DashboardFragment
implements
- LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.AppsStorageResult>> {
+ LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.AppsStorageResult>>,
+ Preference.OnPreferenceClickListener {
private static final String TAG = "StorageDashboardFrag";
private static final String SUMMARY_PREF_KEY = "storage_summary";
+ private static final String FREE_UP_SPACE_PREF_KEY = "free_up_space";
+ private static final String SELECTED_STORAGE_ENTRY_KEY = "selected_storage_entry_key";
private static final int STORAGE_JOB_ID = 0;
private static final int ICON_JOB_ID = 1;
private static final int VOLUME_SIZE_JOB_ID = 2;
- private VolumeInfo mVolume;
+ private StorageManager mStorageManager;
+ private final List<StorageEntry> mStorageEntries = new ArrayList<>();
+ private StorageEntry mSelectedStorageEntry;
private PrivateStorageInfo mStorageInfo;
private SparseArray<StorageAsyncLoader.AppsStorageResult> mAppsResult;
private CachedStorageValuesHelper mCachedStorageValuesHelper;
private StorageItemPreferenceController mPreferenceController;
- private PrivateVolumeOptionMenuController mOptionMenuController;
+ private VolumeOptionMenuController mOptionMenuController;
+ private StorageSelectionPreferenceController mStorageSelectionController;
+ private StorageUsageProgressBarPreferenceController mStorageUsageProgressBarController;
private List<AbstractPreferenceController> mSecondaryUsers;
private boolean mPersonalOnly;
+ private Preference mFreeUpSpacePreference;
+
+ private final StorageEventListener mStorageEventListener = new StorageEventListener() {
+ @Override
+ public void onVolumeStateChanged(VolumeInfo volumeInfo, int oldState, int newState) {
+ if (!isInteresting(volumeInfo)) {
+ return;
+ }
+
+ final StorageEntry changedStorageEntry = new StorageEntry(getContext(), volumeInfo);
+ switch (volumeInfo.getState()) {
+ case VolumeInfo.STATE_MOUNTED:
+ case VolumeInfo.STATE_MOUNTED_READ_ONLY:
+ case VolumeInfo.STATE_UNMOUNTABLE:
+ // Add mounted or unmountable storage in the list and show it on spinner.
+ // Unmountable storages are the storages which has a problem format and android
+ // is not able to mount it automatically.
+ // Users can format an unmountable storage by the UI and then use the storage.
+ mStorageEntries.removeIf(storageEntry -> {
+ return storageEntry.equals(changedStorageEntry);
+ });
+ mStorageEntries.add(changedStorageEntry);
+ if (changedStorageEntry.equals(mSelectedStorageEntry)) {
+ mSelectedStorageEntry = changedStorageEntry;
+ }
+ refreshUi();
+ break;
+ case VolumeInfo.STATE_REMOVED:
+ case VolumeInfo.STATE_UNMOUNTED:
+ case VolumeInfo.STATE_BAD_REMOVAL:
+ case VolumeInfo.STATE_EJECTING:
+ // Remove removed storage from list and don't show it on spinner.
+ if (mStorageEntries.remove(changedStorageEntry)) {
+ if (changedStorageEntry.equals(mSelectedStorageEntry)) {
+ mSelectedStorageEntry =
+ StorageEntry.getDefaultInternalStorageEntry(getContext());
+ }
+ refreshUi();
+ }
+ break;
+ default:
+ // Do nothing.
+ }
+ }
+
+ @Override
+ public void onVolumeRecordChanged(VolumeRecord volumeRecord) {
+ if (isVolumeRecordMissed(volumeRecord)) {
+ // VolumeRecord is a metadata of VolumeInfo, if a VolumeInfo is missing
+ // (e.g., internal SD card is removed.) show the missing storage to users,
+ // users can insert the SD card or manually forget the storage from the device.
+ final StorageEntry storageEntry = new StorageEntry(volumeRecord);
+ if (!mStorageEntries.contains(storageEntry)) {
+ mStorageEntries.add(storageEntry);
+ refreshUi();
+ }
+ } else {
+ // Find mapped VolumeInfo and replace with existing one for something changed.
+ // (e.g., Renamed.)
+ final VolumeInfo mappedVolumeInfo =
+ mStorageManager.findVolumeByUuid(volumeRecord.getFsUuid());
+ if (mappedVolumeInfo == null) {
+ return;
+ }
+
+ final boolean removeMappedStorageEntry = mStorageEntries.removeIf(storageEntry ->
+ storageEntry.isVolumeInfo()
+ && TextUtils.equals(storageEntry.getFsUuid(), volumeRecord.getFsUuid())
+ );
+ if (removeMappedStorageEntry) {
+ mStorageEntries.add(new StorageEntry(getContext(), mappedVolumeInfo));
+ refreshUi();
+ }
+ }
+ }
+
+ @Override
+ public void onVolumeForgotten(String fsUuid) {
+ final StorageEntry storageEntry = new StorageEntry(
+ new VolumeRecord(VolumeInfo.TYPE_PUBLIC, fsUuid));
+ if (mStorageEntries.remove(storageEntry)) {
+ if (mSelectedStorageEntry.equals(storageEntry)) {
+ mSelectedStorageEntry =
+ StorageEntry.getDefaultInternalStorageEntry(getContext());
+ }
+ refreshUi();
+ }
+ }
+
+ @Override
+ public void onDiskScanned(DiskInfo disk, int volumeCount) {
+ if (!isDiskUnsupported(disk)) {
+ return;
+ }
+ final StorageEntry storageEntry = new StorageEntry(disk);
+ if (!mStorageEntries.contains(storageEntry)) {
+ mStorageEntries.add(storageEntry);
+ refreshUi();
+ }
+ }
+
+ @Override
+ public void onDiskDestroyed(DiskInfo disk) {
+ final StorageEntry storageEntry = new StorageEntry(disk);
+ if (mStorageEntries.remove(storageEntry)) {
+ if (mSelectedStorageEntry.equals(storageEntry)) {
+ mSelectedStorageEntry =
+ StorageEntry.getDefaultInternalStorageEntry(getContext());
+ }
+ refreshUi();
+ }
+ }
+ };
+
+ private static boolean isInteresting(VolumeInfo volumeInfo) {
+ switch (volumeInfo.getType()) {
+ case VolumeInfo.TYPE_PRIVATE:
+ case VolumeInfo.TYPE_PUBLIC:
+ case VolumeInfo.TYPE_STUB:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * VolumeRecord is a metadata of VolumeInfo, this is the case where a VolumeInfo is missing.
+ * (e.g., internal SD card is removed.)
+ */
+ private boolean isVolumeRecordMissed(VolumeRecord volumeRecord) {
+ return volumeRecord.getType() == VolumeInfo.TYPE_PRIVATE
+ && mStorageManager.findVolumeByUuid(volumeRecord.getFsUuid()) == null;
+ }
+
+ /**
+ * A unsupported disk is the disk of problem format, android is not able to mount automatically.
+ */
+ private static boolean isDiskUnsupported(DiskInfo disk) {
+ return disk.volumeCount == 0 && disk.size > 0;
+ }
+
+ private void refreshUi() {
+ mStorageSelectionController.setStorageEntries(mStorageEntries);
+ mStorageSelectionController.setSelectedStorageEntry(mSelectedStorageEntry);
+ mStorageUsageProgressBarController.setSelectedStorageEntry(mSelectedStorageEntry);
+
+ mOptionMenuController.setSelectedStorageEntry(mSelectedStorageEntry);
+ getActivity().invalidateOptionsMenu();
+
+ mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
+
+ if (mSelectedStorageEntry.isPrivate() && mSelectedStorageEntry.isMounted()) {
+ // Stats data is only available on private volumes.
+ getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
+ getLoaderManager()
+ .restartLoader(VOLUME_SIZE_JOB_ID, Bundle.EMPTY, new VolumeSizeCallbacks());
+ getLoaderManager().restartLoader(ICON_JOB_ID, Bundle.EMPTY, new IconLoaderCallbacks());
+ } else {
+ // Set null volume to hide category stats.
+ mPreferenceController.setVolume(null);
+ }
+ }
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- // Initialize the storage sizes that we can quickly calc.
final Activity activity = getActivity();
- StorageManager sm = activity.getSystemService(StorageManager.class);
- mVolume = Utils.maybeInitializeVolume(sm, getArguments());
+ mStorageManager = activity.getSystemService(StorageManager.class);
mPersonalOnly = getArguments().getInt(ProfileSelectFragment.EXTRA_PROFILE)
== ProfileSelectFragment.ProfileType.PERSONAL;
- if (mVolume == null) {
- activity.finish();
- return;
+
+ if (icicle == null) {
+ final VolumeInfo specifiedVolumeInfo =
+ Utils.maybeInitializeVolume(mStorageManager, getArguments());
+ mSelectedStorageEntry = specifiedVolumeInfo == null
+ ? StorageEntry.getDefaultInternalStorageEntry(getContext())
+ : new StorageEntry(getContext(), specifiedVolumeInfo);
+ } else {
+ mSelectedStorageEntry = icicle.getParcelable(SELECTED_STORAGE_ENTRY_KEY);
}
+
+ initializePreference();
initializeOptionsMenu(activity);
+ }
+
+ private void initializePreference() {
if (mPersonalOnly) {
final Preference summary = getPreferenceScreen().findPreference(SUMMARY_PREF_KEY);
if (summary != null) {
summary.setVisible(false);
}
}
+ mFreeUpSpacePreference = getPreferenceScreen().findPreference(FREE_UP_SPACE_PREF_KEY);
+ mFreeUpSpacePreference.setOnPreferenceClickListener(this);
}
@Override
@@ -106,12 +299,25 @@
super.onAttach(context);
use(AutomaticStorageManagementSwitchPreferenceController.class).setFragmentManager(
getFragmentManager());
+ mStorageSelectionController = use(StorageSelectionPreferenceController.class);
+ mStorageSelectionController.setOnItemSelectedListener(storageEntry -> {
+ mSelectedStorageEntry = storageEntry;
+ refreshUi();
+
+ if (storageEntry.isDiskInfoUnsupported() || storageEntry.isUnmountable()) {
+ DiskInitFragment.show(this, R.string.storage_dialog_unmountable,
+ storageEntry.getDiskId());
+ } else if (storageEntry.isVolumeRecordMissed()) {
+ StorageUtils.launchForgetMissingVolumeRecordFragment(getContext(), storageEntry);
+ }
+ });
+ mStorageUsageProgressBarController = use(StorageUsageProgressBarPreferenceController.class);
}
@VisibleForTesting
void initializeOptionsMenu(Activity activity) {
- mOptionMenuController = new PrivateVolumeOptionMenuController(
- activity, mVolume, activity.getPackageManager());
+ mOptionMenuController = new VolumeOptionMenuController(activity, this,
+ mSelectedStorageEntry);
getSettingsLifecycle().addObserver(mOptionMenuController);
setHasOptionsMenu(true);
activity.invalidateOptionsMenu();
@@ -133,10 +339,34 @@
@Override
public void onResume() {
super.onResume();
- getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
- getLoaderManager()
- .restartLoader(VOLUME_SIZE_JOB_ID, Bundle.EMPTY, new VolumeSizeCallbacks());
- getLoaderManager().restartLoader(ICON_JOB_ID, Bundle.EMPTY, new IconLoaderCallbacks());
+
+ mStorageEntries.clear();
+ mStorageEntries.addAll(mStorageManager.getVolumes().stream()
+ .filter(volumeInfo -> isInteresting(volumeInfo))
+ .map(volumeInfo -> new StorageEntry(getContext(), volumeInfo))
+ .collect(Collectors.toList()));
+ mStorageEntries.addAll(mStorageManager.getDisks().stream()
+ .filter(disk -> isDiskUnsupported(disk))
+ .map(disk -> new StorageEntry(disk))
+ .collect(Collectors.toList()));
+ mStorageEntries.addAll(mStorageManager.getVolumeRecords().stream()
+ .filter(volumeRecord -> isVolumeRecordMissed(volumeRecord))
+ .map(volumeRecord -> new StorageEntry(volumeRecord))
+ .collect(Collectors.toList()));
+ refreshUi();
+ mStorageManager.registerListener(mStorageEventListener);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mStorageManager.unregisterListener(mStorageEventListener);
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ outState.putParcelable(SELECTED_STORAGE_ENTRY_KEY, mSelectedStorageEntry);
+ super.onSaveInstanceState(outState);
}
@Override
@@ -148,7 +378,7 @@
boolean stopLoading = false;
if (mStorageInfo != null) {
long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
- mPreferenceController.setVolume(mVolume);
+ mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
mPreferenceController.setUsedSize(privateUsedBytes);
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
@@ -197,7 +427,7 @@
StorageManager sm = context.getSystemService(StorageManager.class);
mPreferenceController = new StorageItemPreferenceController(context, this,
- mVolume, new StorageManagerVolumeProvider(sm));
+ null /* volume */, new StorageManagerVolumeProvider(sm));
controllers.add(mPreferenceController);
final UserManager userManager = context.getSystemService(UserManager.class);
@@ -209,7 +439,7 @@
@VisibleForTesting
protected void setVolume(VolumeInfo info) {
- mVolume = info;
+ mSelectedStorageEntry = new StorageEntry(getContext(), info);
}
/**
@@ -260,7 +490,7 @@
Bundle args) {
final Context context = getContext();
return new StorageAsyncLoader(context, context.getSystemService(UserManager.class),
- mVolume.fsUuid,
+ mSelectedStorageEntry.getFsUuid(),
new StorageStatsSource(context),
context.getPackageManager());
}
@@ -277,6 +507,21 @@
public void onLoaderReset(Loader<SparseArray<StorageAsyncLoader.AppsStorageResult>> loader) {
}
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (preference == mFreeUpSpacePreference) {
+ final Context context = getContext();
+ final MetricsFeatureProvider metricsFeatureProvider =
+ FeatureFactory.getFactory(context).getMetricsFeatureProvider();
+ metricsFeatureProvider.logClickedPreference(preference, getMetricsCategory());
+ metricsFeatureProvider.action(context, SettingsEnums.STORAGE_FREE_UP_SPACE_NOW);
+ final Intent intent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
+ context.startActivity(intent);
+ return true;
+ }
+ return false;
+ }
+
@VisibleForTesting
public void setCachedStorageValuesHelper(CachedStorageValuesHelper helper) {
mCachedStorageValuesHelper = helper;
@@ -340,8 +585,9 @@
}
private boolean isQuotaSupported() {
- final StorageStatsManager stats = getActivity().getSystemService(StorageStatsManager.class);
- return stats.isQuotaSupported(mVolume.fsUuid);
+ return mSelectedStorageEntry.isMounted()
+ && getActivity().getSystemService(StorageStatsManager.class)
+ .isQuotaSupported(mSelectedStorageEntry.getFsUuid());
}
/**
@@ -378,11 +624,12 @@
implements LoaderManager.LoaderCallbacks<PrivateStorageInfo> {
@Override
public Loader<PrivateStorageInfo> onCreateLoader(int id, Bundle args) {
- Context context = getContext();
- StorageManager sm = context.getSystemService(StorageManager.class);
- StorageManagerVolumeProvider smvp = new StorageManagerVolumeProvider(sm);
+ final Context context = getContext();
+ final StorageManagerVolumeProvider smvp =
+ new StorageManagerVolumeProvider(mStorageManager);
final StorageStatsManager stats = context.getSystemService(StorageStatsManager.class);
- return new VolumeSizesLoader(context, smvp, stats, mVolume);
+ return new VolumeSizesLoader(context, smvp, stats,
+ mSelectedStorageEntry.getVolumeInfo());
}
@Override
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
index 7d20aa7..9e969a8 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
@@ -121,7 +121,7 @@
try {
moveId = getPackageManager().movePrimaryStorage(mVolume);
} catch (IllegalArgumentException e) {
- StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE);
+ StorageManager sm = getSystemService(StorageManager.class);
if (Objects.equals(mVolume.getFsUuid(), sm.getPrimaryStorageVolume().getUuid())) {
final Intent intent = new Intent(this, StorageWizardReady.class);
diff --git a/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java b/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java
new file mode 100644
index 0000000..0932447
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo;
+
+import android.app.ActivityManager;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.os.UserManager;
+import android.os.storage.DiskInfo;
+import android.os.storage.StorageManager;
+import android.os.storage.VolumeInfo;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.fragment.app.Fragment;
+
+import com.android.settings.R;
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.deviceinfo.StorageSettings.MountTask;
+import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
+import com.android.settings.deviceinfo.storage.StorageEntry;
+import com.android.settings.deviceinfo.storage.StorageRenameFragment;
+import com.android.settings.deviceinfo.storage.StorageUtils;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
+import com.android.settingslib.core.lifecycle.events.OnOptionsItemSelected;
+import com.android.settingslib.core.lifecycle.events.OnPrepareOptionsMenu;
+
+import java.util.Objects;
+
+/**
+ * Handles the option menu on the Storage settings.
+ */
+public class VolumeOptionMenuController implements LifecycleObserver, OnCreateOptionsMenu,
+ OnPrepareOptionsMenu, OnOptionsItemSelected {
+
+ @VisibleForTesting
+ MenuItem mRename;
+ @VisibleForTesting
+ MenuItem mMount;
+ @VisibleForTesting
+ MenuItem mUnmount;
+ @VisibleForTesting
+ MenuItem mFormat;
+ @VisibleForTesting
+ MenuItem mFormatAsPortable;
+ @VisibleForTesting
+ MenuItem mFormatAsInternal;
+ @VisibleForTesting
+ MenuItem mMigrate;
+ @VisibleForTesting
+ MenuItem mFree;
+ @VisibleForTesting
+ MenuItem mForget;
+
+ private final Context mContext;
+ private final Fragment mFragment;
+ private final PackageManager mPackageManager;
+ private final StorageManager mStorageManager;
+ private StorageEntry mStorageEntry;
+
+ public VolumeOptionMenuController(Context context, Fragment parent, StorageEntry storageEntry) {
+ mContext = context;
+ mFragment = parent;
+ mPackageManager = context.getPackageManager();
+ mStorageManager = context.getSystemService(StorageManager.class);
+ mStorageEntry = storageEntry;
+ }
+
+ @Override
+ public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
+ inflater.inflate(R.menu.storage_volume, menu);
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ mRename = menu.findItem(R.id.storage_rename);
+ mMount = menu.findItem(R.id.storage_mount);
+ mUnmount = menu.findItem(R.id.storage_unmount);
+ mFormat = menu.findItem(R.id.storage_format);
+ mFormatAsPortable = menu.findItem(R.id.storage_format_as_portable);
+ mFormatAsInternal = menu.findItem(R.id.storage_format_as_internal);
+ mMigrate = menu.findItem(R.id.storage_migrate);
+ mFree = menu.findItem(R.id.storage_free);
+ mForget = menu.findItem(R.id.storage_forget);
+
+ mRename.setVisible(false);
+ mMount.setVisible(false);
+ mUnmount.setVisible(false);
+ mFormat.setVisible(false);
+ mFormatAsPortable.setVisible(false);
+ mFormatAsInternal.setVisible(false);
+ mMigrate.setVisible(false);
+ mFree.setVisible(false);
+ mForget.setVisible(false);
+
+ if (mStorageEntry.isDiskInfoUnsupported()) {
+ mFormat.setVisible(true);
+ return;
+ }
+ if (mStorageEntry.isVolumeRecordMissed()) {
+ mForget.setVisible(true);
+ return;
+ }
+ if (mStorageEntry.isUnmounted()) {
+ mMount.setVisible(true);
+ return;
+ }
+ if (!mStorageEntry.isMounted()) {
+ return;
+ }
+
+ if (mStorageEntry.isPrivate()) {
+ if (!mStorageEntry.isDefaultInternalStorage()) {
+ mRename.setVisible(true);
+ mUnmount.setVisible(true);
+ mFormatAsPortable.setVisible(true);
+ }
+
+ // Only offer to migrate when not current storage.
+ final VolumeInfo primaryVolumeInfo = mPackageManager.getPrimaryStorageCurrentVolume();
+ final VolumeInfo selectedVolumeInfo = mStorageEntry.getVolumeInfo();
+ mMigrate.setVisible(primaryVolumeInfo != null
+ && primaryVolumeInfo.getType() == VolumeInfo.TYPE_PRIVATE
+ && !Objects.equals(selectedVolumeInfo, primaryVolumeInfo)
+ && primaryVolumeInfo.isMountedWritable());
+ return;
+ }
+
+ if (mStorageEntry.isPublic()) {
+ mRename.setVisible(true);
+ mUnmount.setVisible(true);
+ mFormat.setVisible(true);
+ final DiskInfo diskInfo = mStorageManager.findDiskById(mStorageEntry.getDiskId());
+ mFormatAsInternal.setVisible(diskInfo != null
+ && diskInfo.isAdoptable()
+ && UserManager.get(mContext).isAdminUser()
+ && !ActivityManager.isUserAMonkey());
+ return;
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem menuItem) {
+ if (!mFragment.isAdded()) {
+ return false;
+ }
+
+ final int menuId = menuItem.getItemId();
+ if (menuId == R.id.storage_mount) {
+ if (mStorageEntry.isUnmounted()) {
+ new MountTask(mFragment.getActivity(), mStorageEntry.getVolumeInfo()).execute();
+ return true;
+ }
+ return false;
+ }
+ if (menuId == R.id.storage_unmount) {
+ if (mStorageEntry.isMounted()) {
+ if (mStorageEntry.isPublic()) {
+ new UnmountTask(mFragment.getActivity(),
+ mStorageEntry.getVolumeInfo()).execute();
+ return true;
+ }
+ if (mStorageEntry.isPrivate() && !mStorageEntry.isDefaultInternalStorage()) {
+ final Bundle args = new Bundle();
+ args.putString(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
+ new SubSettingLauncher(mContext)
+ .setDestination(PrivateVolumeUnmount.class.getCanonicalName())
+ .setTitleRes(R.string.storage_menu_unmount)
+ .setSourceMetricsCategory(SettingsEnums.DEVICEINFO_STORAGE)
+ .setArguments(args)
+ .launch();
+ return true;
+ }
+ }
+ return false;
+ }
+ if (menuId == R.id.storage_rename) {
+ if ((mStorageEntry.isPrivate() && !mStorageEntry.isDefaultInternalStorage())
+ || mStorageEntry.isPublic()) {
+ StorageRenameFragment.show(mFragment, mStorageEntry.getVolumeInfo());
+ return true;
+ }
+ return false;
+ }
+ if (menuId == R.id.storage_format) {
+ if (mStorageEntry.isDiskInfoUnsupported() || mStorageEntry.isPublic()) {
+ StorageWizardFormatConfirm.showPublic(mFragment.getActivity(),
+ mStorageEntry.getDiskId());
+ return true;
+ }
+ return false;
+ }
+ if (menuId == R.id.storage_format_as_portable) {
+ if (mStorageEntry.isPrivate()) {
+ final Bundle args = new Bundle();
+ args.putString(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
+ new SubSettingLauncher(mContext)
+ .setDestination(PrivateVolumeFormat.class.getCanonicalName())
+ .setTitleRes(R.string.storage_menu_format)
+ .setSourceMetricsCategory(SettingsEnums.DEVICEINFO_STORAGE)
+ .setArguments(args)
+ .launch();
+ return true;
+ }
+ return false;
+ }
+ if (menuId == R.id.storage_format_as_internal) {
+ if (mStorageEntry.isPublic()) {
+ StorageWizardFormatConfirm.showPrivate(mFragment.getActivity(),
+ mStorageEntry.getDiskId());
+ return true;
+ }
+ return false;
+ }
+ if (menuId == R.id.storage_migrate) {
+ if (mStorageEntry.isPrivate()) {
+ final Intent intent = new Intent(mContext, StorageWizardMigrateConfirm.class);
+ intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
+ mContext.startActivity(intent);
+ return true;
+ }
+ return false;
+ }
+ if (menuId == R.id.storage_forget) {
+ if (mStorageEntry.isVolumeRecordMissed()) {
+ StorageUtils.launchForgetMissingVolumeRecordFragment(mContext, mStorageEntry);
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+
+ public void setSelectedStorageEntry(StorageEntry storageEntry) {
+ mStorageEntry = storageEntry;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index 4af5d79..fcbd5d3 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -146,8 +146,8 @@
// TODO: There may be an avatar setting action we can use here.
final int iconId = bundle.getInt("icon_id", 0);
if (iconId == 0) {
- final UserManager userManager = (UserManager) getActivity().getSystemService(
- Context.USER_SERVICE);
+ final UserManager userManager = getActivity().getSystemService(
+ UserManager.class);
final UserInfo info = Utils.getExistingUser(userManager,
android.os.Process.myUserHandle());
controller.setLabel(info.name);
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
index d6cf442..14e86b4 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
@@ -49,7 +49,7 @@
public FirmwareVersionDetailPreferenceController(Context context, String key) {
super(context, key);
- mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ mUserManager = mContext.getSystemService(UserManager.class);
initializeAdminPermissions();
}
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
index 967eea6..fbb29a7 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
@@ -49,7 +49,7 @@
public ImeiInfoPreferenceController(Context context, String key) {
super(context, key);
- mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ mTelephonyManager = context.getSystemService(TelephonyManager.class);
mIsMultiSim = mTelephonyManager.getPhoneCount() > 1;
}
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceController.java
index 02c1916..c391750 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceController.java
@@ -46,9 +46,9 @@
public SimStatusPreferenceController(Context context, Fragment fragment) {
super(context);
- mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- mSubscriptionManager = (SubscriptionManager) context.getSystemService(
- Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+ mTelephonyManager = context.getSystemService(TelephonyManager.class);
+ mSubscriptionManager = context.getSystemService(
+ SubscriptionManager.class);
mFragment = fragment;
}
diff --git a/src/com/android/settings/deviceinfo/storage/DiskInitFragment.java b/src/com/android/settings/deviceinfo/storage/DiskInitFragment.java
new file mode 100644
index 0000000..1e6a98d
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/storage/DiskInitFragment.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.storage;
+
+import android.app.Dialog;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.storage.DiskInfo;
+import android.os.storage.StorageManager;
+import android.text.TextUtils;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.Fragment;
+
+import com.android.settings.R;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.deviceinfo.StorageWizardInit;
+
+/** A dialog which guides users to initialize a specified unsupported disk. */
+public class DiskInitFragment extends InstrumentedDialogFragment {
+
+ private static final String TAG_DISK_INIT = "disk_init";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.DIALOG_VOLUME_INIT;
+ }
+
+ /** Shows the dialog for the specified diskId from DiskInfo. */
+ public static void show(Fragment parent, int resId, String diskId) {
+ final Bundle args = new Bundle();
+ args.putInt(Intent.EXTRA_TEXT, resId);
+ args.putString(DiskInfo.EXTRA_DISK_ID, diskId);
+
+ final DiskInitFragment dialog = new DiskInitFragment();
+ dialog.setArguments(args);
+ dialog.setTargetFragment(parent, 0);
+ dialog.show(parent.getFragmentManager(), TAG_DISK_INIT);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final Context context = getActivity();
+ final StorageManager storageManager = context.getSystemService(StorageManager.class);
+ final int resId = getArguments().getInt(Intent.EXTRA_TEXT);
+ final String diskId = getArguments().getString(DiskInfo.EXTRA_DISK_ID);
+ final DiskInfo disk = storageManager.findDiskById(diskId);
+
+ final AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ return builder.setMessage(TextUtils.expandTemplate(getText(resId), disk.getDescription()))
+ .setPositiveButton(R.string.storage_menu_set_up, (dialog, which) -> {
+ final Intent intent = new Intent(context, StorageWizardInit.class);
+ intent.putExtra(DiskInfo.EXTRA_DISK_ID, diskId);
+ startActivity(intent); })
+ .setNegativeButton(R.string.cancel, null)
+ .create();
+ }
+}
+
diff --git a/src/com/android/settings/deviceinfo/storage/StorageEntry.java b/src/com/android/settings/deviceinfo/storage/StorageEntry.java
new file mode 100644
index 0000000..f718116
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/storage/StorageEntry.java
@@ -0,0 +1,293 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.storage;
+
+import android.annotation.NonNull;
+import android.content.Context;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.os.storage.DiskInfo;
+import android.os.storage.StorageManager;
+import android.os.storage.VolumeInfo;
+import android.os.storage.VolumeRecord;
+import android.text.TextUtils;
+
+import java.io.File;
+
+/**
+ * This object contains a {@link VolumeInfo} for a mountable storage or a {@link DiskInfo} for an
+ * unsupported disk which is not able to be mounted automatically.
+ */
+public class StorageEntry implements Comparable<StorageEntry>, Parcelable {
+
+ private final VolumeInfo mVolumeInfo;
+ private final DiskInfo mUnsupportedDiskInfo;
+ private final VolumeRecord mMissingVolumeRecord;
+
+ private final String mVolumeInfoDescription;
+
+ public StorageEntry(@NonNull Context context, @NonNull VolumeInfo volumeInfo) {
+ mVolumeInfo = volumeInfo;
+ mUnsupportedDiskInfo = null;
+ mMissingVolumeRecord = null;
+ mVolumeInfoDescription = context.getSystemService(StorageManager.class)
+ .getBestVolumeDescription(mVolumeInfo);
+ }
+
+ public StorageEntry(@NonNull DiskInfo diskInfo) {
+ mVolumeInfo = null;
+ mUnsupportedDiskInfo = diskInfo;
+ mMissingVolumeRecord = null;
+ mVolumeInfoDescription = null;
+ }
+
+ public StorageEntry(@NonNull VolumeRecord volumeRecord) {
+ mVolumeInfo = null;
+ mUnsupportedDiskInfo = null;
+ mMissingVolumeRecord = volumeRecord;
+ mVolumeInfoDescription = null;
+ }
+
+ private StorageEntry(Parcel in) {
+ mVolumeInfo = in.readParcelable(VolumeInfo.class.getClassLoader());
+ mUnsupportedDiskInfo = in.readParcelable(DiskInfo.class.getClassLoader());
+ mMissingVolumeRecord = in.readParcelable(VolumeRecord.class.getClassLoader());
+ mVolumeInfoDescription = in.readString();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(mVolumeInfo, 0 /* parcelableFlags */);
+ out.writeParcelable(mUnsupportedDiskInfo, 0 /* parcelableFlags */);
+ out.writeParcelable(mMissingVolumeRecord , 0 /* parcelableFlags */);
+ out.writeString(mVolumeInfoDescription);
+ }
+
+ public static final Parcelable.Creator<StorageEntry> CREATOR =
+ new Parcelable.Creator<StorageEntry>() {
+ public StorageEntry createFromParcel(Parcel in) {
+ return new StorageEntry(in);
+ }
+
+ public StorageEntry[] newArray(int size) {
+ return new StorageEntry[size];
+ }
+ };
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof StorageEntry)) {
+ return false;
+ }
+
+ final StorageEntry StorageEntry = (StorageEntry) o;
+ if (isVolumeInfo()) {
+ return mVolumeInfo.equals(StorageEntry.mVolumeInfo);
+ }
+ if (isDiskInfoUnsupported()) {
+ return mUnsupportedDiskInfo.equals(StorageEntry.mUnsupportedDiskInfo);
+ }
+ return mMissingVolumeRecord.equals(StorageEntry.mMissingVolumeRecord);
+ }
+
+ @Override
+ public int hashCode() {
+ if (isVolumeInfo()) {
+ return mVolumeInfo.hashCode();
+ }
+ if (isDiskInfoUnsupported()) {
+ return mUnsupportedDiskInfo.hashCode();
+ }
+ return mMissingVolumeRecord.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ if (isVolumeInfo()) {
+ return mVolumeInfo.toString();
+ }
+ if (isDiskInfoUnsupported()) {
+ return mUnsupportedDiskInfo.toString();
+ }
+ return mMissingVolumeRecord.toString();
+ }
+
+ @Override
+ public int compareTo(StorageEntry other) {
+ if (isDefaultInternalStorage() && !other.isDefaultInternalStorage()) {
+ return -1;
+ }
+ if (!isDefaultInternalStorage() && other.isDefaultInternalStorage()) {
+ return 1;
+ }
+
+ if (isVolumeInfo() && !other.isVolumeInfo()) {
+ return -1;
+ }
+ if (!isVolumeInfo() && other.isVolumeInfo()) {
+ return 1;
+ }
+
+ if (isPrivate() && !other.isPrivate()) {
+ return -1;
+ }
+ if (!isPrivate() && other.isPrivate()) {
+ return 1;
+ }
+
+ if (isMounted() && !other.isMounted()) {
+ return -1;
+ }
+ if (!isMounted() && other.isMounted()) {
+ return 1;
+ }
+
+ if (!isVolumeRecordMissed() && other.isVolumeRecordMissed()) {
+ return -1;
+ }
+ if (isVolumeRecordMissed() && !other.isVolumeRecordMissed()) {
+ return 1;
+ }
+
+ if (getDescription() == null) {
+ return 1;
+ }
+ if (other.getDescription() == null) {
+ return -1;
+ }
+ return getDescription().compareTo(other.getDescription());
+ }
+
+ /** Returns default internal storage. */
+ public static StorageEntry getDefaultInternalStorageEntry(Context context) {
+ return new StorageEntry(context, context.getSystemService(StorageManager.class)
+ .findVolumeById(VolumeInfo.ID_PRIVATE_INTERNAL));
+ }
+
+ /** If it's a VolumeInfo. */
+ public boolean isVolumeInfo() {
+ return mVolumeInfo != null;
+ }
+
+ /** If it's an unsupported DiskInfo. */
+ public boolean isDiskInfoUnsupported() {
+ return mUnsupportedDiskInfo != null;
+ }
+
+ /** If it's a missing VolumeRecord. */
+ public boolean isVolumeRecordMissed() {
+ return mMissingVolumeRecord != null;
+ }
+
+ /** If it's a default internal storage. */
+ public boolean isDefaultInternalStorage() {
+ if (isVolumeInfo()) {
+ return mVolumeInfo.getType() == VolumeInfo.TYPE_PRIVATE
+ && TextUtils.equals(mVolumeInfo.getId(), VolumeInfo.ID_PRIVATE_INTERNAL);
+ }
+ return false;
+ }
+
+ /** If it's a mounted storage. */
+ public boolean isMounted() {
+ return mVolumeInfo == null ? false : (mVolumeInfo.getState() == VolumeInfo.STATE_MOUNTED
+ || mVolumeInfo.getState() == VolumeInfo.STATE_MOUNTED_READ_ONLY);
+ }
+
+ /** If it's an unmounted storage. */
+ public boolean isUnmounted() {
+ return mVolumeInfo == null ? false : (mVolumeInfo.getState() == VolumeInfo.STATE_UNMOUNTED);
+ }
+
+ /** If it's an unmountable storage. */
+ public boolean isUnmountable() {
+ return mVolumeInfo == null ? false : mVolumeInfo.getState() == VolumeInfo.STATE_UNMOUNTABLE;
+ }
+
+ /** If it's a private storage. */
+ public boolean isPrivate() {
+ return mVolumeInfo == null ? false : mVolumeInfo.getType() == VolumeInfo.TYPE_PRIVATE;
+ }
+
+ /** If it's a public storage. */
+ public boolean isPublic() {
+ return mVolumeInfo == null ? false : mVolumeInfo.getType() == VolumeInfo.TYPE_PUBLIC;
+ }
+
+ /** Returns description. */
+ public String getDescription() {
+ if (isVolumeInfo()) {
+ return mVolumeInfoDescription;
+ }
+ if (isDiskInfoUnsupported()) {
+ return mUnsupportedDiskInfo.getDescription();
+ }
+ return mMissingVolumeRecord.getNickname();
+ }
+
+ /** Returns ID. */
+ public String getId() {
+ if (isVolumeInfo()) {
+ return mVolumeInfo.getId();
+ }
+ if (isDiskInfoUnsupported()) {
+ return mUnsupportedDiskInfo.getId();
+ }
+ return mMissingVolumeRecord.getFsUuid();
+ }
+
+ /** Returns disk ID. */
+ public String getDiskId() {
+ if (isVolumeInfo()) {
+ return mVolumeInfo.getDiskId();
+ }
+ if (isDiskInfoUnsupported()) {
+ return mUnsupportedDiskInfo.getId();
+ }
+ return null;
+ }
+
+ /** Returns fsUuid. */
+ public String getFsUuid() {
+ if (isVolumeInfo()) {
+ return mVolumeInfo.getFsUuid();
+ }
+ if (isDiskInfoUnsupported()) {
+ return null;
+ }
+ return mMissingVolumeRecord.getFsUuid();
+ }
+
+ /** Returns root file if it's a VolumeInfo. */
+ public File getPath() {
+ return mVolumeInfo == null ? null : mVolumeInfo.getPath();
+ }
+
+ /** Returns VolumeInfo of the StorageEntry. */
+ public VolumeInfo getVolumeInfo() {
+ return mVolumeInfo;
+ }
+}
+
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index c2a0b62..e007090 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -158,6 +158,9 @@
intent = getAppsIntent();
break;
case FILES_KEY:
+ if (mVolume == null) {
+ break;
+ }
intent = getFilesIntent();
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider().action(
mContext, SettingsEnums.STORAGE_FILES);
@@ -189,7 +192,27 @@
*/
public void setVolume(VolumeInfo volume) {
mVolume = volume;
- setFilesPreferenceVisibility();
+ updateCategoryPreferencesVisibility();
+ }
+
+ private void updateCategoryPreferencesVisibility() {
+ // Stats data is only available on private volumes.
+ final boolean isValidVolume = mVolume != null
+ && mVolume.getType() == VolumeInfo.TYPE_PRIVATE
+ && (mVolume.getState() == VolumeInfo.STATE_MOUNTED
+ || mVolume.getState() == VolumeInfo.STATE_MOUNTED_READ_ONLY);
+
+ mPhotoPreference.setVisible(isValidVolume);
+ mAudioPreference.setVisible(isValidVolume);
+ mGamePreference.setVisible(isValidVolume);
+ mMoviesPreference.setVisible(isValidVolume);
+ mAppPreference.setVisible(isValidVolume);
+ mFilePreference.setVisible(isValidVolume);
+ mSystemPreference.setVisible(isValidVolume);
+
+ if (isValidVolume) {
+ setFilesPreferenceVisibility();
+ }
}
private void setFilesPreferenceVisibility() {
@@ -248,7 +271,7 @@
mSystemPreference = screen.findPreference(SYSTEM_KEY);
mFilePreference = screen.findPreference(FILES_KEY);
- setFilesPreferenceVisibility();
+ updateCategoryPreferencesVisibility();
}
public void onLoadFinished(SparseArray<StorageAsyncLoader.AppsStorageResult> result,
diff --git a/src/com/android/settings/deviceinfo/storage/StorageRenameFragment.java b/src/com/android/settings/deviceinfo/storage/StorageRenameFragment.java
new file mode 100644
index 0000000..c67fe33
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/storage/StorageRenameFragment.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.storage;
+
+import android.app.Dialog;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.storage.StorageManager;
+import android.os.storage.VolumeInfo;
+import android.os.storage.VolumeRecord;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.EditText;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.Fragment;
+
+import com.android.settings.R;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+
+/**
+ * Dialog that allows editing of volume nickname.
+ */
+public class StorageRenameFragment extends InstrumentedDialogFragment {
+ private static final String TAG_RENAME = "rename";
+
+ /** Shows the rename dialog. */
+ public static void show(Fragment parent, VolumeInfo vol) {
+ final StorageRenameFragment dialog = new StorageRenameFragment();
+ dialog.setTargetFragment(parent, 0 /* requestCode */);
+ final Bundle args = new Bundle();
+ args.putString(VolumeRecord.EXTRA_FS_UUID, vol.getFsUuid());
+ dialog.setArguments(args);
+ dialog.show(parent.getFragmentManager(), TAG_RENAME);
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.DIALOG_VOLUME_RENAME;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final Context context = getActivity();
+ final StorageManager storageManager = context.getSystemService(StorageManager.class);
+
+ final String fsUuid = getArguments().getString(VolumeRecord.EXTRA_FS_UUID);
+ final VolumeRecord rec = storageManager.findRecordByUuid(fsUuid);
+
+ final AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
+
+ final View view = dialogInflater.inflate(R.layout.dialog_edittext, null, false);
+ final EditText nickname = (EditText) view.findViewById(R.id.edittext);
+ nickname.setText(rec.getNickname());
+
+ return builder.setTitle(R.string.storage_rename_title)
+ .setView(view)
+ .setPositiveButton(R.string.save, (dialog, which) ->
+ // TODO: move to background thread
+ storageManager.setVolumeNickname(fsUuid, nickname.getText().toString()))
+ .setNegativeButton(R.string.cancel, null)
+ .create();
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
new file mode 100644
index 0000000..03fddec
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.storage;
+
+import android.content.Context;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.TextView;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.widget.SettingsSpinnerPreference;
+import com.android.settingslib.widget.settingsspinner.SettingsSpinnerAdapter;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Shows a spinner for users to select a storage volume.
+ */
+public class StorageSelectionPreferenceController extends BasePreferenceController implements
+ AdapterView.OnItemSelectedListener {
+
+ @VisibleForTesting
+ SettingsSpinnerPreference mSpinnerPreference;
+ @VisibleForTesting
+ StorageAdapter mStorageAdapter;
+
+ private final List<StorageEntry> mStorageEntries = new ArrayList<>();
+
+ /** The interface for spinner selection callback. */
+ public interface OnItemSelectedListener {
+ /** Callbacked when the spinner selection is changed. */
+ void onItemSelected(StorageEntry storageEntry);
+ }
+ private OnItemSelectedListener mOnItemSelectedListener;
+
+ public StorageSelectionPreferenceController(Context context, String key) {
+ super(context, key);
+
+ mStorageAdapter = new StorageAdapter(context);
+ }
+
+ public void setOnItemSelectedListener(OnItemSelectedListener listener) {
+ mOnItemSelectedListener = listener;
+ }
+
+ /** Set the storages in the spinner. */
+ public void setStorageEntries(List<StorageEntry> storageEntries) {
+ mStorageAdapter.clear();
+ mStorageEntries.clear();
+ if (storageEntries == null || storageEntries.isEmpty()) {
+ return;
+ }
+ Collections.sort(mStorageEntries);
+ mStorageEntries.addAll(storageEntries);
+ mStorageAdapter.addAll(storageEntries);
+ }
+
+ /** set selected storage in the spinner. */
+ public void setSelectedStorageEntry(StorageEntry selectedStorageEntry) {
+ if (mSpinnerPreference == null || !mStorageEntries.contains(selectedStorageEntry)) {
+ return;
+ }
+ mSpinnerPreference.setSelection(mStorageAdapter.getPosition(selectedStorageEntry));
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE_UNSEARCHABLE;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ mSpinnerPreference = screen.findPreference(getPreferenceKey());
+ mSpinnerPreference.setAdapter(mStorageAdapter);
+ mSpinnerPreference.setOnItemSelectedListener(this);
+ }
+
+ @Override
+ public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) {
+ if (mOnItemSelectedListener == null) {
+ return;
+ }
+ mOnItemSelectedListener.onItemSelected(mStorageAdapter.getItem(position));
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ // Do nothing.
+ }
+
+ @VisibleForTesting
+ class StorageAdapter extends SettingsSpinnerAdapter<StorageEntry> {
+
+ StorageAdapter(Context context) {
+ super(context);
+ }
+
+ @Override
+ public View getView(int position, View view, ViewGroup parent) {
+ if (view == null) {
+ view = getDefaultView(position, view, parent);
+ }
+
+ TextView textView = null;
+ try {
+ textView = (TextView) view;
+ } catch (ClassCastException e) {
+ throw new IllegalStateException("Default view should be a TextView, ", e);
+ }
+ textView.setText(getItem(position).getDescription());
+ return textView;
+ }
+
+ @Override
+ public View getDropDownView(int position, View view, ViewGroup parent) {
+ if (view == null) {
+ view = getDefaultDropDownView(position, view, parent);
+ }
+
+ TextView textView = null;
+ try {
+ textView = (TextView) view;
+ } catch (ClassCastException e) {
+ throw new IllegalStateException("Default drop down view should be a TextView, ", e);
+ }
+ textView.setText(getItem(position).getDescription());
+ return textView;
+ }
+ }
+}
+
diff --git a/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceController.java
new file mode 100644
index 0000000..a00b25a
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceController.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.storage;
+
+import android.app.usage.StorageStatsManager;
+import android.content.Context;
+import android.text.format.Formatter;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.utils.ThreadUtils;
+import com.android.settingslib.widget.UsageProgressBarPreference;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Shows storage summary and progress.
+ */
+public class StorageUsageProgressBarPreferenceController extends BasePreferenceController {
+
+ private static final String TAG = "StorageProgressCtrl";
+
+ private final StorageStatsManager mStorageStatsManager;
+ @VisibleForTesting
+ long mUsedBytes;
+ @VisibleForTesting
+ long mTotalBytes;
+ private UsageProgressBarPreference mUsageProgressBarPreference;
+ private StorageEntry mStorageEntry;
+
+ public StorageUsageProgressBarPreferenceController(Context context, String key) {
+ super(context, key);
+
+ mStorageStatsManager = context.getSystemService(StorageStatsManager.class);
+ }
+
+ /** Set StorageEntry to display. */
+ public void setSelectedStorageEntry(StorageEntry storageEntry) {
+ mStorageEntry = storageEntry;
+ getStorageStatsAndUpdateUi();
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE_UNSEARCHABLE;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ mUsageProgressBarPreference = screen.findPreference(getPreferenceKey());
+ getStorageStatsAndUpdateUi();
+ }
+
+ private void getStorageStatsAndUpdateUi() {
+ ThreadUtils.postOnBackgroundThread(() -> {
+ try {
+ if (mStorageEntry == null || !mStorageEntry.isMounted()) {
+ throw new IOException();
+ }
+
+ if (mStorageEntry.isPrivate()) {
+ // StorageStatsManager can only query private storages.
+ mTotalBytes = mStorageStatsManager.getTotalBytes(mStorageEntry.getFsUuid());
+ mUsedBytes = mTotalBytes
+ - mStorageStatsManager.getFreeBytes(mStorageEntry.getFsUuid());
+ } else {
+ final File rootFile = mStorageEntry.getPath();
+ if (rootFile == null) {
+ Log.d(TAG, "Mounted public storage has null root path: " + mStorageEntry);
+ throw new IOException();
+ }
+ mTotalBytes = rootFile.getTotalSpace();
+ mUsedBytes = mTotalBytes - rootFile.getFreeSpace();
+ }
+ } catch (IOException e) {
+ // The storage device isn't present.
+ mTotalBytes = 0;
+ mUsedBytes = 0;
+ }
+
+ if (mUsageProgressBarPreference == null) {
+ return;
+ }
+ ThreadUtils.postOnMainThread(() ->
+ updateState(mUsageProgressBarPreference)
+ );
+ });
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ mUsageProgressBarPreference.setUsageSummary(
+ getStorageSummary(R.string.storage_usage_summary, mUsedBytes));
+ mUsageProgressBarPreference.setTotalSummary(
+ getStorageSummary(R.string.storage_total_summary, mTotalBytes));
+ mUsageProgressBarPreference.setPercent(mUsedBytes, mTotalBytes);
+ }
+
+ private String getStorageSummary(int resId, long bytes) {
+ final Formatter.BytesResult result = Formatter.formatBytes(mContext.getResources(),
+ bytes, 0);
+ return mContext.getString(resId, result.value, result.units);
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageUtils.java b/src/com/android/settings/deviceinfo/storage/StorageUtils.java
new file mode 100644
index 0000000..26bdec0
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/storage/StorageUtils.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.storage;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.storage.VolumeRecord;
+
+import com.android.settings.R;
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.deviceinfo.PrivateVolumeForget;
+
+/** Storage utilities */
+public class StorageUtils {
+
+ /** Launches the fragment to forget a specified missing volume record. */
+ public static void launchForgetMissingVolumeRecordFragment(Context context,
+ StorageEntry storageEntry) {
+ if (storageEntry == null || !storageEntry.isVolumeRecordMissed()) {
+ return;
+ }
+
+ final Bundle args = new Bundle();
+ args.putString(VolumeRecord.EXTRA_FS_UUID, storageEntry.getFsUuid());
+ new SubSettingLauncher(context)
+ .setDestination(PrivateVolumeForget.class.getCanonicalName())
+ .setTitleRes(R.string.storage_menu_forget)
+ .setSourceMetricsCategory(SettingsEnums.SETTINGS_STORAGE_CATEGORY)
+ .setArguments(args)
+ .launch();
+ }
+}
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceController.java b/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceController.java
index b07eb91..8353d20 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceController.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceController.java
@@ -13,6 +13,9 @@
*/
package com.android.settings.enterprise;
+import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
+
+import android.app.admin.DevicePolicyManager;
import android.content.Context;
import androidx.preference.Preference;
@@ -39,6 +42,10 @@
if (preference == null) {
return;
}
+ if (isFinancedDevice()) {
+ preference.setTitle(R.string.financed_privacy_settings);
+ }
+
final String organizationName = mFeatureProvider.getDeviceOwnerOrganizationName();
if (organizationName == null) {
preference.setSummary(R.string.enterprise_privacy_settings_summary_generic);
@@ -57,4 +64,10 @@
public String getPreferenceKey() {
return KEY_ENTERPRISE_PRIVACY;
}
+
+ private boolean isFinancedDevice() {
+ final DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
+ return dpm.isDeviceManaged() && dpm.getDeviceOwnerType(
+ dpm.getDeviceOwnerComponentOnAnyUser()) == DEVICE_OWNER_TYPE_FINANCED;
+ }
}
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
index dd0a9ce..1aad544 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
@@ -20,16 +20,13 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
-import com.android.settings.R;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.PreferenceCategoryController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
@SearchIndexable
@@ -37,6 +34,23 @@
static final String TAG = "EnterprisePrivacySettings";
+ @VisibleForTesting
+ PrivacySettingsPreference mPrivacySettingsPreference;
+
+ @Override
+ public void onAttach(Context context) {
+ mPrivacySettingsPreference =
+ PrivacySettingsPreferenceFactory.createPrivacySettingsPreference(context);
+
+ super.onAttach(context);
+ }
+
+ @Override
+ public void onDetach() {
+ mPrivacySettingsPreference = null;
+ super.onDetach();
+ }
+
@Override
public int getMetricsCategory() {
return SettingsEnums.ENTERPRISE_PRIVACY_SETTINGS;
@@ -49,47 +63,12 @@
@Override
protected int getPreferenceScreenResId() {
- return R.xml.enterprise_privacy_settings;
+ return mPrivacySettingsPreference.getPreferenceScreenResId();
}
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, true /* async */);
- }
-
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- boolean async) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new NetworkLogsPreferenceController(context));
- controllers.add(new BugReportsPreferenceController(context));
- controllers.add(new SecurityLogsPreferenceController(context));
- final List<AbstractPreferenceController> exposureChangesCategoryControllers =
- new ArrayList<>();
- exposureChangesCategoryControllers.add(new EnterpriseInstalledPackagesPreferenceController(
- context, async));
- exposureChangesCategoryControllers.add(
- new AdminGrantedLocationPermissionsPreferenceController(context, async));
- exposureChangesCategoryControllers.add(
- new AdminGrantedMicrophonePermissionPreferenceController(context, async));
- exposureChangesCategoryControllers.add(new AdminGrantedCameraPermissionPreferenceController(
- context, async));
- exposureChangesCategoryControllers.add(new EnterpriseSetDefaultAppsPreferenceController(
- context));
- exposureChangesCategoryControllers.add(new AlwaysOnVpnCurrentUserPreferenceController(
- context));
- exposureChangesCategoryControllers.add(new AlwaysOnVpnManagedProfilePreferenceController(
- context));
- exposureChangesCategoryControllers.add(new ImePreferenceController(context));
- exposureChangesCategoryControllers.add(new GlobalHttpProxyPreferenceController(context));
- exposureChangesCategoryControllers.add(new CaCertsCurrentUserPreferenceController(context));
- exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController(
- context));
- controllers.addAll(exposureChangesCategoryControllers);
- controllers.add(new PreferenceCategoryController(context, "exposure_changes_category")
- .setChildren(exposureChangesCategoryControllers));
- controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(context));
- controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context));
- return controllers;
+ return mPrivacySettingsPreference.createPreferenceControllers(true /* async */);
}
public static boolean isPageEnabled(Context context) {
@@ -99,17 +78,32 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.enterprise_privacy_settings) {
+ new BaseSearchIndexProvider() {
+
+ private PrivacySettingsPreference mPrivacySettingsPreference;
+
@Override
protected boolean isPageSearchEnabled(Context context) {
return isPageEnabled(context);
}
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ mPrivacySettingsPreference =
+ PrivacySettingsPreferenceFactory.createPrivacySettingsPreference(
+ context);
+ return mPrivacySettingsPreference.getXmlResourcesToIndex();
+ }
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
- return buildPreferenceControllers(context, false /* async */);
+ mPrivacySettingsPreference =
+ PrivacySettingsPreferenceFactory.createPrivacySettingsPreference(
+ context);
+ return mPrivacySettingsPreference.createPreferenceControllers(
+ false /* async */);
}
};
}
diff --git a/src/com/android/settings/enterprise/PrivacySettingsEnterprisePreference.java b/src/com/android/settings/enterprise/PrivacySettingsEnterprisePreference.java
new file mode 100644
index 0000000..19556a1
--- /dev/null
+++ b/src/com/android/settings/enterprise/PrivacySettingsEnterprisePreference.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.settings.R;
+import com.android.settings.widget.PreferenceCategoryController;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/** Privacy Settings preferences for an Enterprise device. */
+public class PrivacySettingsEnterprisePreference implements PrivacySettingsPreference {
+ private static final String KEY_EXPOSURE_CHANGES_CATEGORY = "exposure_changes_category";
+
+ private final Context mContext;
+
+ public PrivacySettingsEnterprisePreference(Context context) {
+ mContext = context.getApplicationContext();
+ }
+
+ /**
+ * Returns the XML Res Id that is used for an Enterprise device in the Privacy Settings screen.
+ */
+ @Override
+ public int getPreferenceScreenResId() {
+ return R.xml.enterprise_privacy_settings;
+ }
+
+ /**
+ * Returns the Enterprise XML resources to index for an Enterprise device.
+ */
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex() {
+ final SearchIndexableResource sir = new SearchIndexableResource(mContext);
+ sir.xmlResId = getPreferenceScreenResId();
+ return Collections.singletonList(sir);
+ }
+
+ /**
+ * Returns the preference controllers used to populate the privacy preferences in the Privacy
+ * Settings screen for Enterprise devices.
+ */
+ @Override
+ public List<AbstractPreferenceController> createPreferenceControllers(boolean async) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ controllers.add(new NetworkLogsPreferenceController(mContext));
+ controllers.add(new BugReportsPreferenceController(mContext));
+ controllers.add(new SecurityLogsPreferenceController(mContext));
+ final List<AbstractPreferenceController> exposureChangesCategoryControllers =
+ new ArrayList<>();
+ exposureChangesCategoryControllers.add(new EnterpriseInstalledPackagesPreferenceController(
+ mContext, async));
+ exposureChangesCategoryControllers.add(
+ new AdminGrantedLocationPermissionsPreferenceController(mContext, async));
+ exposureChangesCategoryControllers.add(
+ new AdminGrantedMicrophonePermissionPreferenceController(mContext, async));
+ exposureChangesCategoryControllers.add(new AdminGrantedCameraPermissionPreferenceController(
+ mContext, async));
+ exposureChangesCategoryControllers.add(new EnterpriseSetDefaultAppsPreferenceController(
+ mContext));
+ exposureChangesCategoryControllers.add(new AlwaysOnVpnCurrentUserPreferenceController(
+ mContext));
+ exposureChangesCategoryControllers.add(new AlwaysOnVpnManagedProfilePreferenceController(
+ mContext));
+ exposureChangesCategoryControllers.add(new ImePreferenceController(mContext));
+ exposureChangesCategoryControllers.add(new GlobalHttpProxyPreferenceController(mContext));
+ exposureChangesCategoryControllers.add(new CaCertsCurrentUserPreferenceController(
+ mContext));
+ exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController(
+ mContext));
+ controllers.addAll(exposureChangesCategoryControllers);
+ controllers.add(new PreferenceCategoryController(mContext, KEY_EXPOSURE_CHANGES_CATEGORY)
+ .setChildren(exposureChangesCategoryControllers));
+ controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(mContext));
+ controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(mContext));
+ return controllers;
+ }
+}
diff --git a/src/com/android/settings/enterprise/PrivacySettingsFinancedPreference.java b/src/com/android/settings/enterprise/PrivacySettingsFinancedPreference.java
new file mode 100644
index 0000000..12901a6
--- /dev/null
+++ b/src/com/android/settings/enterprise/PrivacySettingsFinancedPreference.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.settings.R;
+import com.android.settings.widget.PreferenceCategoryController;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/** Privacy Settings preferences for a financed device. */
+public class PrivacySettingsFinancedPreference implements PrivacySettingsPreference {
+ private static final String KEY_EXPOSURE_CHANGES_CATEGORY = "exposure_changes_category";
+
+ private final Context mContext;
+
+ public PrivacySettingsFinancedPreference(Context context) {
+ mContext = context.getApplicationContext();
+ }
+
+ /**
+ * Returns the XML Res Id that is used for financed devices in the Privacy Settings screen.
+ */
+ @Override
+ public int getPreferenceScreenResId() {
+ return R.xml.financed_privacy_settings;
+ }
+
+ /**
+ * Returns the XML resources to index for a financed device.
+ */
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex() {
+ final SearchIndexableResource sir = new SearchIndexableResource(mContext);
+ sir.xmlResId = getPreferenceScreenResId();
+ return Collections.singletonList(sir);
+ }
+
+ /**
+ * Returns the preference controllers used to populate the privacy preferences in the Privacy
+ * Settings screen for a financed device.
+ */
+ @Override
+ public List<AbstractPreferenceController> createPreferenceControllers(boolean async) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ controllers.add(new NetworkLogsPreferenceController(mContext));
+ controllers.add(new BugReportsPreferenceController(mContext));
+ controllers.add(new SecurityLogsPreferenceController(mContext));
+ final List<AbstractPreferenceController> exposureChangesCategoryControllers =
+ new ArrayList<>();
+ exposureChangesCategoryControllers.add(new EnterpriseInstalledPackagesPreferenceController(
+ mContext, async));
+ controllers.addAll(exposureChangesCategoryControllers);
+ controllers.add(new PreferenceCategoryController(mContext, KEY_EXPOSURE_CHANGES_CATEGORY)
+ .setChildren(exposureChangesCategoryControllers));
+ controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(mContext));
+ return controllers;
+ }
+}
diff --git a/src/com/android/settings/enterprise/PrivacySettingsPreference.java b/src/com/android/settings/enterprise/PrivacySettingsPreference.java
new file mode 100644
index 0000000..4310f5e
--- /dev/null
+++ b/src/com/android/settings/enterprise/PrivacySettingsPreference.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import android.provider.SearchIndexableResource;
+
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.util.List;
+
+/** Interface for configuring what is displayed on the Privacy Settings. */
+public interface PrivacySettingsPreference {
+
+ /**
+ * Returns the XML Res Id that is used in the Privacy Settings screen.
+ */
+ int getPreferenceScreenResId();
+
+ /**
+ * Returns the XML resources to index.
+ */
+ List<SearchIndexableResource> getXmlResourcesToIndex();
+
+ /**
+ * Returns the preference controllers used to populate the privacy preferences.
+ */
+ List<AbstractPreferenceController> createPreferenceControllers(boolean async);
+}
diff --git a/src/com/android/settings/enterprise/PrivacySettingsPreferenceFactory.java b/src/com/android/settings/enterprise/PrivacySettingsPreferenceFactory.java
new file mode 100644
index 0000000..0ec2498
--- /dev/null
+++ b/src/com/android/settings/enterprise/PrivacySettingsPreferenceFactory.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+
+/** Factory for creating the privacy settings preference for a managed device. */
+public class PrivacySettingsPreferenceFactory {
+
+ /**
+ * Determines which preference to use in the Privacy Settings based off of the type of managed
+ * device.
+ */
+ public static PrivacySettingsPreference createPrivacySettingsPreference(Context context) {
+ if (isFinancedDevice(context)) {
+ return createPrivacySettingsFinancedPreference(context);
+ } else {
+ return createPrivacySettingsEnterprisePreference(context);
+ }
+ }
+
+ private static PrivacySettingsEnterprisePreference createPrivacySettingsEnterprisePreference(
+ Context context) {
+ return new PrivacySettingsEnterprisePreference(context);
+ }
+
+ private static PrivacySettingsFinancedPreference createPrivacySettingsFinancedPreference(
+ Context context) {
+ return new PrivacySettingsFinancedPreference(context);
+ }
+
+ private static boolean isFinancedDevice(Context context) {
+ final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
+ return dpm.isDeviceManaged() && dpm.getDeviceOwnerType(
+ dpm.getDeviceOwnerComponentOnAnyUser()) == DEVICE_OWNER_TYPE_FINANCED;
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index 47b2a0a..a55d0d3 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -257,6 +257,27 @@
BatteryEntry.startRequestQueue();
}
+ /**
+ * Gets the BatteryEntry list by using the supplied BatteryUsageStats.
+ */
+ public List<BatteryEntry> getBatteryEntryList(
+ BatteryUsageStats batteryUsageStats, boolean showAllApps) {
+ mBatteryUsageStats = USE_FAKE_DATA ? getFakeStats() : batteryUsageStats;
+ if (!sConfig.shouldShowBatteryAttributionList(mContext)) {
+ return null;
+ }
+ final int dischargePercentage = getDischargePercentage(batteryUsageStats);
+ final List<BatteryEntry> usageList = getCoalescedUsageList(showAllApps);
+ final double totalPower = batteryUsageStats.getConsumedPower();
+ for (int i = 0; i < usageList.size(); i++) {
+ final BatteryEntry entry = usageList.get(i);
+ final double percentOfTotal = mBatteryUtils.calculateBatteryPercent(
+ entry.getConsumedPower(), totalPower, dischargePercentage);
+ entry.percent = percentOfTotal;
+ }
+ return usageList;
+ }
+
private int getDischargePercentage(BatteryUsageStats batteryUsageStats) {
int dischargePercentage = batteryUsageStats.getDischargePercentage();
if (dischargePercentage < 0) {
@@ -311,7 +332,7 @@
final int index = batteryEntryList.indexOfKey(realUid);
if (index < 0) {
// New entry.
- batteryEntryList.put(realUid, new BatteryEntry(mActivity, mHandler, mUserManager,
+ batteryEntryList.put(realUid, new BatteryEntry(mContext, mHandler, mUserManager,
consumer, isHidden, packages, null));
} else {
// Combine BatterySippers if we already have one with this UID.
@@ -328,7 +349,7 @@
continue;
}
- results.add(new BatteryEntry(mActivity, mHandler, mUserManager,
+ results.add(new BatteryEntry(mContext, mHandler, mUserManager,
consumer, /* isHidden */ true, null, null));
}
@@ -337,7 +358,7 @@
mBatteryUsageStats.getUserBatteryConsumers();
for (int i = 0, size = userBatteryConsumers.size(); i < size; i++) {
final UserBatteryConsumer consumer = userBatteryConsumers.get(i);
- results.add(new BatteryEntry(mActivity, mHandler, mUserManager,
+ results.add(new BatteryEntry(mContext, mHandler, mUserManager,
consumer, /* isHidden */ true, null, null));
}
}
diff --git a/src/com/android/settings/fuelgauge/BatteryEntry.java b/src/com/android/settings/fuelgauge/BatteryEntry.java
index 9fafefd..6c3add3 100644
--- a/src/com/android/settings/fuelgauge/BatteryEntry.java
+++ b/src/com/android/settings/fuelgauge/BatteryEntry.java
@@ -35,6 +35,7 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
+import android.util.Pair;
import androidx.annotation.NonNull;
@@ -182,49 +183,10 @@
getQuickNameIconForUid(uid, packages);
return;
} else if (batteryConsumer instanceof SystemBatteryConsumer) {
- switch(((SystemBatteryConsumer) batteryConsumer).getDrainType()) {
- case SystemBatteryConsumer.DRAIN_TYPE_AMBIENT_DISPLAY:
- name = context.getResources().getString(R.string.ambient_display_screen_title);
- iconId = R.drawable.ic_settings_aod;
- break;
- case SystemBatteryConsumer.DRAIN_TYPE_BLUETOOTH:
- name = context.getResources().getString(R.string.power_bluetooth);
- iconId = com.android.internal.R.drawable.ic_settings_bluetooth;
- break;
- case SystemBatteryConsumer.DRAIN_TYPE_CAMERA:
- name = context.getResources().getString(R.string.power_camera);
- iconId = R.drawable.ic_settings_camera;
- break;
- case SystemBatteryConsumer.DRAIN_TYPE_MOBILE_RADIO:
- name = context.getResources().getString(R.string.power_cell);
- iconId = R.drawable.ic_cellular_1_bar;
- break;
- case SystemBatteryConsumer.DRAIN_TYPE_FLASHLIGHT:
- name = context.getResources().getString(R.string.power_flashlight);
- iconId = R.drawable.ic_settings_display;
- break;
- case SystemBatteryConsumer.DRAIN_TYPE_PHONE:
- name = context.getResources().getString(R.string.power_phone);
- iconId = R.drawable.ic_settings_voice_calls;
- break;
- case SystemBatteryConsumer.DRAIN_TYPE_SCREEN:
- name = context.getResources().getString(R.string.power_screen);
- iconId = R.drawable.ic_settings_display;
- break;
- case SystemBatteryConsumer.DRAIN_TYPE_WIFI:
- name = context.getResources().getString(R.string.power_wifi);
- iconId = R.drawable.ic_settings_wireless;
- break;
- case SystemBatteryConsumer.DRAIN_TYPE_IDLE:
- case SystemBatteryConsumer.DRAIN_TYPE_MEMORY:
- name = context.getResources().getString(R.string.power_idle);
- iconId = R.drawable.ic_settings_phone_idle;
- break;
- case SystemBatteryConsumer.DRAIN_TYPE_CUSTOM:
- name = null;
- iconId = R.drawable.ic_power_system;
- break;
- }
+ final Pair<Integer, String> resourcePair = getResourcePairFromDrainType(
+ context, ((SystemBatteryConsumer) batteryConsumer).getDrainType());
+ iconId = resourcePair.first;
+ name = resourcePair.second;
} else if (batteryConsumer instanceof UserBatteryConsumer) {
UserInfo info = um.getUserInfo(((UserBatteryConsumer) batteryConsumer).getUserId());
if (info != null) {
@@ -493,4 +455,57 @@
((UidBatteryConsumer) batteryConsumer).getPackageWithHighestDrain();
}
}
+
+ /**
+ * Gets icon ID and name from system battery consumer drain type.
+ */
+ public static Pair<Integer, String> getResourcePairFromDrainType(
+ Context context, int drainType) {
+ String name = null;
+ int iconId = 0;
+ switch (drainType) {
+ case SystemBatteryConsumer.DRAIN_TYPE_AMBIENT_DISPLAY:
+ name = context.getResources().getString(R.string.ambient_display_screen_title);
+ iconId = R.drawable.ic_settings_aod;
+ break;
+ case SystemBatteryConsumer.DRAIN_TYPE_BLUETOOTH:
+ name = context.getResources().getString(R.string.power_bluetooth);
+ iconId = com.android.internal.R.drawable.ic_settings_bluetooth;
+ break;
+ case SystemBatteryConsumer.DRAIN_TYPE_CAMERA:
+ name = context.getResources().getString(R.string.power_camera);
+ iconId = R.drawable.ic_settings_camera;
+ break;
+ case SystemBatteryConsumer.DRAIN_TYPE_MOBILE_RADIO:
+ name = context.getResources().getString(R.string.power_cell);
+ iconId = R.drawable.ic_cellular_1_bar;
+ break;
+ case SystemBatteryConsumer.DRAIN_TYPE_FLASHLIGHT:
+ name = context.getResources().getString(R.string.power_flashlight);
+ iconId = R.drawable.ic_settings_display;
+ break;
+ case SystemBatteryConsumer.DRAIN_TYPE_PHONE:
+ name = context.getResources().getString(R.string.power_phone);
+ iconId = R.drawable.ic_settings_voice_calls;
+ break;
+ case SystemBatteryConsumer.DRAIN_TYPE_SCREEN:
+ name = context.getResources().getString(R.string.power_screen);
+ iconId = R.drawable.ic_settings_display;
+ break;
+ case SystemBatteryConsumer.DRAIN_TYPE_WIFI:
+ name = context.getResources().getString(R.string.power_wifi);
+ iconId = R.drawable.ic_settings_wireless;
+ break;
+ case SystemBatteryConsumer.DRAIN_TYPE_IDLE:
+ case SystemBatteryConsumer.DRAIN_TYPE_MEMORY:
+ name = context.getResources().getString(R.string.power_idle);
+ iconId = R.drawable.ic_settings_phone_idle;
+ break;
+ case SystemBatteryConsumer.DRAIN_TYPE_CUSTOM:
+ name = null;
+ iconId = R.drawable.ic_power_system;
+ break;
+ }
+ return new Pair<>(Integer.valueOf(iconId), name);
+ }
}
diff --git a/src/com/android/settings/fuelgauge/BatterySettingsFeatureProvider.java b/src/com/android/settings/fuelgauge/BatterySettingsFeatureProvider.java
new file mode 100644
index 0000000..73b875b
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/BatterySettingsFeatureProvider.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+/**
+ * Feature provider for battery settings usage.
+ */
+public interface BatterySettingsFeatureProvider {
+
+ /**
+ * Get replacement activity for a given activity or fragment path.
+ */
+ String getReplacingActivityName(String activity);
+
+}
diff --git a/src/com/android/settings/fuelgauge/BatterySettingsFeatureProviderImpl.java b/src/com/android/settings/fuelgauge/BatterySettingsFeatureProviderImpl.java
new file mode 100644
index 0000000..e410695
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/BatterySettingsFeatureProviderImpl.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+/**
+ * Feature provider implementation for battery settings usage.
+ */
+public class BatterySettingsFeatureProviderImpl implements BatterySettingsFeatureProvider {
+
+ @Override
+ public String getReplacingActivityName(String activity) {
+ return null;
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 661c1ea..68a0b03 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -28,13 +28,11 @@
import android.os.BatteryUsageStats;
import android.os.BatteryUsageStatsQuery;
import android.os.Build;
-import android.os.Bundle;
import android.os.Process;
import android.os.SystemBatteryConsumer;
import android.os.SystemClock;
import android.os.UidBatteryConsumer;
import android.os.UserHandle;
-import android.os.UserManager;
import android.util.Log;
import androidx.annotation.IntDef;
@@ -42,7 +40,6 @@
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;
-import com.android.internal.os.BatteryStatsHelper;
import com.android.internal.util.ArrayUtils;
import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
import com.android.settings.fuelgauge.batterytip.AnomalyInfo;
@@ -84,10 +81,8 @@
private static final String TAG = "BatteryUtils";
- private static final int MIN_POWER_THRESHOLD_MILLI_AMP = 5;
private static final double MIN_POWER_THRESHOLD_MILLI_AMP_HOURS = 0.002;
- private static final int SECONDS_IN_HOUR = 60 * 60;
private static BatteryUtils sInstance;
private PackageManager mPackageManager;
@@ -303,7 +298,7 @@
*/
public long calculateLastFullChargeTime(BatteryUsageStats batteryUsageStats,
long currentTimeMs) {
- return currentTimeMs - batteryUsageStats.getStatsStartRealtime();
+ return currentTimeMs - batteryUsageStats.getStatsStartTimestamp();
}
public static void logRuntime(String tag, String message, long startTime) {
@@ -371,13 +366,6 @@
}
}
- public void initBatteryStatsHelper(BatteryStatsHelper statsHelper, Bundle bundle,
- UserManager userManager) {
- statsHelper.create(bundle);
- statsHelper.clearStats();
- statsHelper.refreshStats(BatteryStats.STATS_SINCE_CHARGED, userManager.getUserProfiles());
- }
-
@WorkerThread
public BatteryInfo getBatteryInfo(final String tag) {
final BatteryStatsManager systemService = mContext.getSystemService(
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
index 433c06d..1052afe 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
@@ -28,7 +28,6 @@
import com.android.settings.fuelgauge.batterytip.detectors.HighUsageDetector;
import com.android.settings.fuelgauge.batterytip.detectors.LowBatteryDetector;
import com.android.settings.fuelgauge.batterytip.detectors.SmartBatteryDetector;
-import com.android.settings.fuelgauge.batterytip.detectors.SummaryDetector;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
@@ -73,7 +72,6 @@
tips.add(new SmartBatteryDetector(policy, context.getContentResolver()).detect());
tips.add(new EarlyWarningDetector(policy, context).detect());
tips.add(new BatteryDefenderDetector(batteryInfo).detect());
- tips.add(new SummaryDetector(policy, batteryInfo.averageTimeToDischarge).detect());
// Disable this feature now since it introduces false positive cases. We will try to improve
// it in the future.
// tips.add(new RestrictAppDetector(context, policy).detect());
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicy.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicy.java
index 487adf8..3fbbf5b 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicy.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicy.java
@@ -230,7 +230,7 @@
}
batteryTipEnabled = mParser.getBoolean(KEY_BATTERY_TIP_ENABLED, true);
- summaryEnabled = mParser.getBoolean(KEY_SUMMARY_ENABLED, true);
+ summaryEnabled = mParser.getBoolean(KEY_SUMMARY_ENABLED, false);
batterySaverTipEnabled = mParser.getBoolean(KEY_BATTERY_SAVER_TIP_ENABLED, true);
highUsageEnabled = mParser.getBoolean(KEY_HIGH_USAGE_ENABLED, true);
highUsageAppCount = mParser.getInt(KEY_HIGH_USAGE_APP_COUNT, 3);
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
index 4317bff..00b1e87 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
@@ -28,11 +28,9 @@
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
-import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.CardPreference;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-import com.android.settingslib.fuelgauge.EstimateKt;
import java.util.HashMap;
import java.util.List;
@@ -91,10 +89,8 @@
mPrefContext = screen.getContext();
mCardPreference = screen.findPreference(getPreferenceKey());
- // Add summary tip in advance to avoid UI flakiness
- final SummaryTip summaryTip = new SummaryTip(BatteryTip.StateType.NEW,
- EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
- summaryTip.updatePreference(mCardPreference);
+ // Set preference as invisible since there is no default tips.
+ mCardPreference.setVisible(false);
}
public void updateBatteryTips(List<BatteryTip> batteryTips) {
@@ -110,10 +106,12 @@
}
}
+ mCardPreference.setVisible(false);
for (int i = 0, size = batteryTips.size(); i < size; i++) {
final BatteryTip batteryTip = mBatteryTips.get(i);
batteryTip.validateCheck(mContext);
if (batteryTip.getState() != BatteryTip.StateType.INVISIBLE) {
+ mCardPreference.setVisible(true);
batteryTip.updatePreference(mCardPreference);
mBatteryTipMap.put(mCardPreference.getKey(), batteryTip);
batteryTip.log(mContext, mMetricsFeatureProvider);
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/EarlyWarningDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/EarlyWarningDetector.java
index 9b6b9b5..f7a4f8c 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/EarlyWarningDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/EarlyWarningDetector.java
@@ -56,7 +56,7 @@
EarlyWarningDetector.class.getName()) || mPolicy.testBatterySaverTip;
final int state = powerSaveModeOn
- ? BatteryTip.StateType.HANDLED
+ ? BatteryTip.StateType.INVISIBLE
: mPolicy.batterySaverTipEnabled && discharging && earlyWarning
? BatteryTip.StateType.NEW
: BatteryTip.StateType.INVISIBLE;
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java
index ca9141d..75f47a7 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java
@@ -49,16 +49,16 @@
final boolean lowBattery = mBatteryInfo.batteryLevel <= mWarningLevel
|| (mBatteryInfo.discharging && mBatteryInfo.remainingTimeUs != 0
&& mBatteryInfo.remainingTimeUs < TimeUnit.HOURS.toMicros(mPolicy.lowBatteryHour));
+ final boolean lowBatteryEnabled = mPolicy.lowBatteryEnabled && !powerSaveModeOn;
+ final boolean dischargingLowBatteryState =
+ mPolicy.testLowBatteryTip || (mBatteryInfo.discharging && lowBattery);
int state = BatteryTip.StateType.INVISIBLE;
- if (mPolicy.lowBatteryEnabled) {
- if (powerSaveModeOn) {
- // Show it is handled if battery saver is on
- state = BatteryTip.StateType.HANDLED;
- } else if (mPolicy.testLowBatteryTip || (mBatteryInfo.discharging && lowBattery)) {
- // Show it is new if in test or in discharging low battery state
- state = BatteryTip.StateType.NEW;
- }
+
+ // Show it as new if in test or in discharging low battery state,
+ // dismiss it if battery saver is on or disabled by config.
+ if (lowBatteryEnabled && dischargingLowBatteryState) {
+ state = BatteryTip.StateType.NEW;
}
return new LowBatteryTip(
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/EarlyWarningTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/EarlyWarningTip.java
index 0c2bb03..6701314 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/EarlyWarningTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/EarlyWarningTip.java
@@ -18,7 +18,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.content.res.ColorStateList;
import android.os.Parcel;
import com.android.settings.R;
@@ -43,31 +42,23 @@
@Override
public CharSequence getTitle(Context context) {
return context.getString(
- mState == StateType.HANDLED
- ? R.string.battery_tip_early_heads_up_done_title
- : R.string.battery_tip_early_heads_up_title);
+ mState = R.string.battery_tip_early_heads_up_title);
}
@Override
public CharSequence getSummary(Context context) {
return context.getString(
- mState == StateType.HANDLED
- ? R.string.battery_tip_early_heads_up_done_summary
- : R.string.battery_tip_early_heads_up_summary);
+ mState = R.string.battery_tip_early_heads_up_summary);
}
@Override
public int getIconId() {
- return mState == StateType.HANDLED
- ? R.drawable.ic_battery_status_maybe_24dp
- : R.drawable.ic_battery_status_bad_24dp;
+ return mState = R.drawable.ic_battery_status_bad_24dp;
}
@Override
public int getIconTintColorId() {
- return mState == StateType.HANDLED
- ? R.color.battery_maybe_color_light
- : R.color.battery_bad_color_light;
+ return mState = R.color.battery_bad_color_light;
}
@Override
@@ -76,9 +67,9 @@
if (earlyWarningTip.mState == StateType.NEW) {
// Display it if there is early warning
mState = StateType.NEW;
- } else if (mState == StateType.NEW && earlyWarningTip.mState == StateType.INVISIBLE) {
- // If powerSaveMode is really on, show it as handled, otherwise just dismiss it.
- mState = earlyWarningTip.mPowerSaveModeOn ? StateType.HANDLED : StateType.INVISIBLE;
+ } else if (earlyWarningTip.mPowerSaveModeOn) {
+ // If powerSaveMode is really on, dismiss it.
+ mState = StateType.INVISIBLE;
} else {
mState = earlyWarningTip.getState();
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java
index d7acdd2..7790b10 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java
@@ -21,7 +21,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import com.android.settings.R;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
/**
@@ -43,8 +42,7 @@
@Override
public CharSequence getSummary(Context context) {
- return mState == StateType.HANDLED ? context.getString(
- R.string.battery_tip_early_heads_up_done_summary) : mSummary;
+ return mSummary;
}
@Override
diff --git a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java
index c6db4ea..03bd195 100644
--- a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java
+++ b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java
@@ -17,7 +17,6 @@
package com.android.settings.gestures;
import android.content.Context;
-import android.os.SystemProperties;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
@@ -28,15 +27,13 @@
**/
public class OneHandedEnablePreferenceController extends TogglePreferenceController {
- static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";
-
public OneHandedEnablePreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
- return SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)
+ return OneHandedSettingsUtils.isSupportOneHandedMode()
? BasePreferenceController.AVAILABLE
: BasePreferenceController.UNSUPPORTED_ON_DEVICE;
}
@@ -45,6 +42,7 @@
public boolean setChecked(boolean isChecked) {
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext,
isChecked);
+ OneHandedSettingsUtils.setSwipeDownNotificationEnabled(mContext, !isChecked);
return true;
}
diff --git a/src/com/android/settings/gestures/OneHandedSettings.java b/src/com/android/settings/gestures/OneHandedSettings.java
index 2449cf2..6a07c85 100644
--- a/src/com/android/settings/gestures/OneHandedSettings.java
+++ b/src/com/android/settings/gestures/OneHandedSettings.java
@@ -18,7 +18,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.os.SystemProperties;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -52,8 +51,7 @@
new BaseSearchIndexProvider(R.xml.one_handed_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
- return SystemProperties.getBoolean(
- OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, false);
+ return OneHandedSettingsUtils.isSupportOneHandedMode();
}
};
}
diff --git a/src/com/android/settings/gestures/OneHandedSettingsUtils.java b/src/com/android/settings/gestures/OneHandedSettingsUtils.java
index f3d7e33..ed0f62f 100644
--- a/src/com/android/settings/gestures/OneHandedSettingsUtils.java
+++ b/src/com/android/settings/gestures/OneHandedSettingsUtils.java
@@ -22,6 +22,7 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
+import android.os.SystemProperties;
import android.provider.Settings;
/**
@@ -29,6 +30,8 @@
*/
public class OneHandedSettingsUtils {
+ static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";
+
public enum OneHandedTimeout {
NEVER(0), SHORT(4), MEDIUM(8), LONG(12);
@@ -52,6 +55,13 @@
}
/**
+ * Get One-Handed mode support flag.
+ */
+ public static boolean isSupportOneHandedMode() {
+ return SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false);
+ }
+
+ /**
* Get one-handed mode enable or disable flag from Settings provider.
*
* @param context App context
@@ -119,6 +129,28 @@
}
/**
+ * Get Swipe-down-notification enable or disable flag from Settings provider.
+ *
+ * @param context App context
+ * @return enable or disable Swipe-down-notification flag.
+ */
+ public static boolean isSwipeDownNotificationEnabled(Context context) {
+ return Settings.Secure.getInt(context.getContentResolver(),
+ Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0) == 1;
+ }
+
+ /**
+ * Set Swipe-down-notification enable or disable flag to Settings provider.
+ *
+ * @param context App context
+ * @param enable enable or disable Swipe-down-notification.
+ */
+ public static void setSwipeDownNotificationEnabled(Context context, boolean enable) {
+ Settings.Secure.putInt(context.getContentResolver(),
+ Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, enable ? 1 : 0);
+ }
+
+ /**
* Register callback for observing Settings.Secure.ONE_HANDED_MODE_ENABLED state.
* @param callback for state changes
*/
diff --git a/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceController.java b/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceController.java
index 04a32de..28441cd 100644
--- a/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceController.java
+++ b/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceController.java
@@ -16,14 +16,8 @@
package com.android.settings.gestures;
-import static android.provider.Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED;
-
-import static com.android.settings.gestures.OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE;
import android.content.Context;
-import android.os.SystemProperties;
-import android.provider.Settings;
-import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
@@ -33,32 +27,20 @@
**/
public class SwipeBottomToNotificationPreferenceController extends TogglePreferenceController {
- private static final int ON = 1;
- private static final int OFF = 0;
-
private static final String PREF_KEY = "gesture_swipe_bottom_to_notification";
public SwipeBottomToNotificationPreferenceController(Context context, String key) {
super(context, key);
}
- /** Indicates whether the gesture is available or not. */
- public static boolean isGestureAvailable(Context context) {
- // Disable the gesture once One-Handed mode gesture enabled.
- if (SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) {
- return !OneHandedSettingsUtils.isOneHandedModeEnabled(context);
- }
- return true;
- }
-
@Override
public int getAvailabilityStatus() {
- return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+ return OneHandedSettingsUtils.isSupportOneHandedMode() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isSliceable() {
- return TextUtils.equals(getPreferenceKey(), PREF_KEY);
+ return true;
}
@Override
@@ -68,15 +50,16 @@
@Override
public boolean setChecked(boolean isChecked) {
- Settings.Secure.putInt(mContext.getContentResolver(),
- SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, isChecked ? ON : OFF);
+ if (isChecked) {
+ OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, false);
+ }
+ OneHandedSettingsUtils.setSwipeDownNotificationEnabled(mContext, isChecked);
return true;
}
@Override
public boolean isChecked() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, ON) == ON;
+ return OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext);
}
@Override
diff --git a/src/com/android/settings/gestures/SwipeBottomToNotificationSettings.java b/src/com/android/settings/gestures/SwipeBottomToNotificationSettings.java
index d0441f3..9d85f11 100644
--- a/src/com/android/settings/gestures/SwipeBottomToNotificationSettings.java
+++ b/src/com/android/settings/gestures/SwipeBottomToNotificationSettings.java
@@ -50,8 +50,10 @@
@Override
protected boolean isPageSearchEnabled(Context context) {
- return SwipeBottomToNotificationPreferenceController
- .isGestureAvailable(context);
+ if (!OneHandedSettingsUtils.isSupportOneHandedMode()) {
+ return false;
+ }
+ return !OneHandedSettingsUtils.isOneHandedModeEnabled(context);
}
};
}
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index aa7b2d1..881e39c 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -43,6 +43,25 @@
private static final String TAG = "SettingsHomepageActivity";
+ private static final long HOMEPAGE_LOADING_TIMEOUT_MS = 300;
+
+ private View mHomepageView;
+ private View mSuggestionView;
+
+ /**
+ * Shows the homepage and shows/hides the suggestion together. Only allows to be executed once
+ * to avoid the flicker caused by the suggestion suddenly appearing/disappearing.
+ */
+ public void showHomepageWithSuggestion(boolean showSuggestion) {
+ if (mHomepageView == null) {
+ return;
+ }
+ Log.i(TAG, "showHomepageWithSuggestion: " + showSuggestion);
+ mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
+ mHomepageView.setVisibility(View.VISIBLE);
+ mHomepageView = null;
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -56,15 +75,23 @@
FeatureFactory.getFactory(this).getSearchFeatureProvider()
.initSearchToolbar(this /* activity */, toolbar, SettingsEnums.SETTINGS_HOMEPAGE);
- final ImageView avatarView = findViewById(R.id.account_avatar);
- getLifecycle().addObserver(new AvatarViewMixin(this, avatarView));
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
if (!getSystemService(ActivityManager.class).isLowRamDevice()) {
- // Only allow contextual features on high ram devices.
+ // Only allow features on high ram devices.
+ final ImageView avatarView = findViewById(R.id.account_avatar);
+ if (AvatarViewMixin.isAvatarSupported(this)) {
+ avatarView.setVisibility(View.VISIBLE);
+ getLifecycle().addObserver(new AvatarViewMixin(this, avatarView));
+ }
+
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SILKY_HOME)) {
showSuggestionFragment();
+ } else {
+ findViewById(R.id.homepage_title).setVisibility(View.GONE);
+ avatarView.setVisibility(View.GONE);
}
+
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.CONTEXTUAL_HOME)) {
showFragment(new ContextualCardsFragment(), R.id.contextual_cards_content);
}
@@ -81,9 +108,16 @@
return;
}
+ mSuggestionView = findViewById(R.id.suggestion_content);
+ mHomepageView = findViewById(R.id.settings_homepage_container);
+ // Hide the homepage for preparing the suggestion.
+ mHomepageView.setVisibility(View.GONE);
+ // Schedule a timer to show the homepage and hide the suggestion on timeout.
+ mHomepageView.postDelayed(() -> showHomepageWithSuggestion(false),
+ HOMEPAGE_LOADING_TIMEOUT_MS);
try {
- showFragment(fragment.newInstance(), R.id.contextual_suggestion_content);
- } catch (IllegalAccessException | InstantiationException e) {
+ showFragment(fragment.getConstructor().newInstance(), R.id.suggestion_content);
+ } catch (Exception e) {
Log.w(TAG, "Cannot show fragment", e);
}
}
@@ -110,10 +144,7 @@
private int getSearchBoxHeight() {
final int searchBarHeight = getResources().getDimensionPixelSize(R.dimen.search_bar_height);
- final int searchBarMarginTop = getResources().getDimensionPixelSize(
- R.dimen.search_bar_margin);
- final int searchBarMarginBottom = getResources().getDimensionPixelSize(
- R.dimen.search_bar_margin_bottom);
- return searchBarHeight + searchBarMarginTop + searchBarMarginBottom;
+ final int searchBarMargin = getResources().getDimensionPixelSize(R.dimen.search_bar_margin);
+ return searchBarHeight + searchBarMargin * 2;
}
}
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/AirplaneModeConditionController.java b/src/com/android/settings/homepage/contextualcards/conditional/AirplaneModeConditionController.java
index 2f55b3f..8bd3028 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/AirplaneModeConditionController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/AirplaneModeConditionController.java
@@ -40,11 +40,13 @@
private final ConditionManager mConditionManager;
private final Context mAppContext;
private final Receiver mReceiver;
+ private final ConnectivityManager mConnectivityManager;
public AirplaneModeConditionController(Context appContext, ConditionManager conditionManager) {
mAppContext = appContext;
mConditionManager = conditionManager;
mReceiver = new Receiver();
+ mConnectivityManager = mAppContext.getSystemService(ConnectivityManager.class);
}
@Override
@@ -65,7 +67,7 @@
@Override
public void onActionClick() {
- ConnectivityManager.from(mAppContext).setAirplaneMode(false);
+ mConnectivityManager.setAirplaneMode(false);
}
@Override
diff --git a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
index 686558c..d41a378 100644
--- a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
@@ -91,11 +91,19 @@
List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
final Context context = getPrefContext();
final List<InputMethodInfo> imis = mInputMethodSettingValues.getInputMethodList();
+ final List<InputMethodInfo> enabledImis = mImm.getEnabledInputMethodList();
final int numImis = (imis == null ? 0 : imis.size());
for (int i = 0; i < numImis; ++i) {
final InputMethodInfo imi = imis.get(i);
+ // TODO (b/182876800): Move this logic out of isAllowedByOrganization and
+ // into a new boolean.
+ // If an input method is enabled but not included in the permitted list, then set it as
+ // allowed by organization. Doing so will allow the user to disable the input method and
+ // remain complaint with the organization's policy. Once disabled, the input method
+ // cannot be re-enabled because it is not in the permitted list.
final boolean isAllowedByOrganization = permittedList == null
- || permittedList.contains(imi.getPackageName());
+ || permittedList.contains(imi.getPackageName())
+ || enabledImis.contains(imi);
final InputMethodPreference pref = new InputMethodPreference(
context, imi, true, isAllowedByOrganization, this);
pref.setIcon(imi.loadIcon(context.getPackageManager()));
diff --git a/src/com/android/settings/network/EthernetTetherPreferenceController.java b/src/com/android/settings/network/EthernetTetherPreferenceController.java
index 06cd6a7..3559edb 100644
--- a/src/com/android/settings/network/EthernetTetherPreferenceController.java
+++ b/src/com/android/settings/network/EthernetTetherPreferenceController.java
@@ -43,7 +43,7 @@
super(context, preferenceKey);
mEthernetRegex = context.getString(
com.android.internal.R.string.config_ethernet_iface_regex);
- mEthernetManager = (EthernetManager) context.getSystemService(Context.ETHERNET_SERVICE);
+ mEthernetManager = context.getSystemService(EthernetManager.class);
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
diff --git a/src/com/android/settings/network/InternetPreferenceController.java b/src/com/android/settings/network/InternetPreferenceController.java
index a6c8574..639bab5 100644
--- a/src/com/android/settings/network/InternetPreferenceController.java
+++ b/src/com/android/settings/network/InternetPreferenceController.java
@@ -75,7 +75,7 @@
private static Map<Integer, Integer> sSummaryMap = new HashMap<>();
static {
sSummaryMap.put(INTERNET_OFF, R.string.condition_airplane_title);
- sSummaryMap.put(INTERNET_NETWORKS_AVAILABLE, R.string.disconnected);
+ sSummaryMap.put(INTERNET_NETWORKS_AVAILABLE, R.string.networks_available);
sSummaryMap.put(INTERNET_WIFI, 0);
sSummaryMap.put(INTERNET_CELLULAR, 0);
sSummaryMap.put(INTERNET_ETHERNET, R.string.to_switch_networks_disconnect_ethernet);
diff --git a/src/com/android/settings/network/InternetUpdater.java b/src/com/android/settings/network/InternetUpdater.java
index 2f704e7..3967276 100644
--- a/src/com/android/settings/network/InternetUpdater.java
+++ b/src/com/android/settings/network/InternetUpdater.java
@@ -32,7 +32,6 @@
import android.net.ConnectivityManager.NetworkCallback;
import android.net.Network;
import android.net.NetworkCapabilities;
-import android.net.NetworkCapabilities.Transport;
import android.net.wifi.WifiManager;
import android.util.Log;
@@ -132,7 +131,7 @@
@VisibleForTesting
boolean mInternetAvailable;
@VisibleForTesting
- @Transport int mTransport;
+ int mTransport;
private static Map<Integer, Integer> sTransportMap = new HashMap<>();
static {
sTransportMap.put(TRANSPORT_WIFI, INTERNET_WIFI);
@@ -227,7 +226,7 @@
}
boolean internetAvailable = false;
- for (@Transport int transport : networkCapabilities.getTransportTypes()) {
+ for (int transport : networkCapabilities.getTransportTypes()) {
if (sTransportMap.containsKey(transport)) {
mTransport = transport;
internetAvailable = true;
diff --git a/src/com/android/settings/network/MobilePlanPreferenceController.java b/src/com/android/settings/network/MobilePlanPreferenceController.java
index d8963ad..65439bc 100644
--- a/src/com/android/settings/network/MobilePlanPreferenceController.java
+++ b/src/com/android/settings/network/MobilePlanPreferenceController.java
@@ -73,9 +73,9 @@
MobilePlanPreferenceHost host) {
super(context);
mHost = host;
- mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- mTm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ mCm = context.getSystemService(ConnectivityManager.class);
+ mTm = context.getSystemService(TelephonyManager.class);
+ mUserManager = context.getSystemService(UserManager.class);
mIsSecondaryUser = !mUserManager.isAdminUser();
}
diff --git a/src/com/android/settings/network/NetworkProviderSettings.java b/src/com/android/settings/network/NetworkProviderSettings.java
index 803b981..1d8ee7a 100644
--- a/src/com/android/settings/network/NetworkProviderSettings.java
+++ b/src/com/android/settings/network/NetworkProviderSettings.java
@@ -1129,7 +1129,7 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem item = menu.add(0, MENU_FIX_CONNECTIVITY, 0, R.string.fix_connectivity);
- item.setIcon(R.drawable.ic_refresh_24dp);
+ item.setIcon(R.drawable.ic_repair_24dp);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
super.onCreateOptionsMenu(menu, inflater);
}
diff --git a/src/com/android/settings/network/NetworkResetRestrictionChecker.java b/src/com/android/settings/network/NetworkResetRestrictionChecker.java
index 46227f9..c873f9d 100644
--- a/src/com/android/settings/network/NetworkResetRestrictionChecker.java
+++ b/src/com/android/settings/network/NetworkResetRestrictionChecker.java
@@ -31,7 +31,7 @@
public NetworkResetRestrictionChecker(Context context) {
mContext = context;
- mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ mUserManager = context.getSystemService(UserManager.class);
}
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
diff --git a/src/com/android/settings/network/NetworkScorerPicker.java b/src/com/android/settings/network/NetworkScorerPicker.java
index 9ecab3b..011cf05 100644
--- a/src/com/android/settings/network/NetworkScorerPicker.java
+++ b/src/com/android/settings/network/NetworkScorerPicker.java
@@ -140,6 +140,6 @@
@VisibleForTesting
NetworkScoreManager createNetworkScorerManager(Context context) {
- return (NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
+ return context.getSystemService(NetworkScoreManager.class);
}
}
diff --git a/src/com/android/settings/network/NetworkScorerPickerPreferenceController.java b/src/com/android/settings/network/NetworkScorerPickerPreferenceController.java
index 4b452c0..2abe390 100644
--- a/src/com/android/settings/network/NetworkScorerPickerPreferenceController.java
+++ b/src/com/android/settings/network/NetworkScorerPickerPreferenceController.java
@@ -37,7 +37,7 @@
public NetworkScorerPickerPreferenceController(Context context, String key) {
super(context, key);
mNetworkScoreManager =
- (NetworkScoreManager) mContext.getSystemService(Context.NETWORK_SCORE_SERVICE);
+ mContext.getSystemService(NetworkScoreManager.class);
}
@Override
diff --git a/src/com/android/settings/network/ProviderModelSliceHelper.java b/src/com/android/settings/network/ProviderModelSliceHelper.java
index 440d425..3a0ceeac 100644
--- a/src/com/android/settings/network/ProviderModelSliceHelper.java
+++ b/src/com/android/settings/network/ProviderModelSliceHelper.java
@@ -24,6 +24,7 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.net.wifi.WifiManager;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
@@ -231,6 +232,7 @@
}
private String getMobileSummary(String networkTypeDescription) {
+ final WifiManager wifiManager = mContext.getSystemService(WifiManager.class);
String summary = networkTypeDescription;
if (isDataSimActive()) {
summary = mContext.getString(R.string.preference_summary_default_combination,
@@ -238,6 +240,8 @@
networkTypeDescription);
} else if (!isMobileDataEnabled()) {
summary = mContext.getString(R.string.mobile_data_off_summary);
+ } else if (!wifiManager.isWifiEnabled() && !isDataSimActive()) {
+ summary = mContext.getString(R.string.mobile_data_no_connection);
}
return summary;
}
diff --git a/src/com/android/settings/network/TetherEnabler.java b/src/com/android/settings/network/TetherEnabler.java
index ef031f6..550d324 100644
--- a/src/com/android/settings/network/TetherEnabler.java
+++ b/src/com/android/settings/network/TetherEnabler.java
@@ -128,10 +128,10 @@
mSwitchWidgetController = switchWidgetController;
mDataSaverBackend = new DataSaverBackend(context);
mConnectivityManager =
- (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- mTetheringManager = (TetheringManager) context.getSystemService(Context.TETHERING_SERVICE);
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ context.getSystemService(ConnectivityManager.class);
+ mTetheringManager = context.getSystemService(TetheringManager.class);
+ mWifiManager = context.getSystemService(WifiManager.class);
+ mUserManager = context.getSystemService(UserManager.class);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothPan = bluetoothPan;
mEthernetRegex =
diff --git a/src/com/android/settings/network/VpnPreferenceController.java b/src/com/android/settings/network/VpnPreferenceController.java
index e815d49..3116dd4 100644
--- a/src/com/android/settings/network/VpnPreferenceController.java
+++ b/src/com/android/settings/network/VpnPreferenceController.java
@@ -27,6 +27,8 @@
import android.os.UserManager;
import android.provider.Settings;
import android.provider.SettingsSlicesContract;
+import android.security.Credentials;
+import android.security.LegacyVpnProfileStore;
import android.util.Log;
import android.util.SparseArray;
@@ -36,8 +38,11 @@
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
+import com.android.internal.net.VpnProfile;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.vpn2.VpnInfoPreference;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -147,6 +152,10 @@
} else {
summary = getNameForVpnConfig(vpn, UserHandle.of(uid));
}
+ // Optionally add warning icon if an insecure VPN is present.
+ if (Utils.isProviderModelEnabled(mContext) && mPreference instanceof VpnInfoPreference) {
+ ((VpnInfoPreference) mPreference).setInsecureVpn(hasInsecureVpn());
+ }
ThreadUtils.postOnMainThread(() -> mPreference.setSummary(summary));
}
@@ -167,6 +176,20 @@
}
}
+ @VisibleForTesting
+ protected boolean hasInsecureVpn() {
+ for (String key : LegacyVpnProfileStore.list(Credentials.VPN)) {
+ final VpnProfile profile = VpnProfile.decode(key,
+ LegacyVpnProfileStore.get(Credentials.VPN + key));
+ // Return whether any profile is an insecure type.
+ if (VpnProfile.isLegacyType(profile.type)) {
+ return true;
+ }
+ }
+ // We did not find any insecure VPNs.
+ return false;
+ }
+
// Copied from SystemUI::SecurityControllerImpl
private final ConnectivityManager.NetworkCallback
mNetworkCallback = new ConnectivityManager.NetworkCallback() {
diff --git a/src/com/android/settings/network/apn/ApnEditor.java b/src/com/android/settings/network/apn/ApnEditor.java
index afc68d5..78b7ccc 100644
--- a/src/com/android/settings/network/apn/ApnEditor.java
+++ b/src/com/android/settings/network/apn/ApnEditor.java
@@ -1291,8 +1291,8 @@
mReadOnlyApnTypes = null;
mReadOnlyApnFields = null;
- final CarrierConfigManager configManager = (CarrierConfigManager)
- getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ final CarrierConfigManager configManager =
+ getSystemService(CarrierConfigManager.class);
if (configManager != null) {
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
if (b != null) {
diff --git a/src/com/android/settings/network/apn/ApnSettings.java b/src/com/android/settings/network/apn/ApnSettings.java
index 02d9b3d..3ba667c 100755
--- a/src/com/android/settings/network/apn/ApnSettings.java
+++ b/src/com/android/settings/network/apn/ApnSettings.java
@@ -209,8 +209,8 @@
mSubscriptionInfo = getSubscriptionInfo(mSubId);
mTelephonyManager = activity.getSystemService(TelephonyManager.class);
- final CarrierConfigManager configManager = (CarrierConfigManager)
- getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ final CarrierConfigManager configManager =
+ getSystemService(CarrierConfigManager.class);
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
mHideImsApn = b.getBoolean(CarrierConfigManager.KEY_HIDE_IMS_APN_BOOL);
mAllowAddingApns = b.getBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL);
diff --git a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
index 1f1cb37..5ea7c20 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
@@ -34,6 +34,7 @@
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
+import com.android.internal.telephony.util.ArrayUtils;
import com.android.settings.R;
import com.android.settings.network.ims.VolteQueryImsState;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -95,9 +96,10 @@
mShow5gLimitedDialog = carrierConfig.getBoolean(
CarrierConfigManager.KEY_VOLTE_5G_LIMITED_ALERT_DIALOG_BOOL);
- mIsNrEnabledFromCarrierConfig = carrierConfig.getInt(
- CarrierConfigManager.KEY_CARRIER_NR_AVAILABILITY_INT)
- != CarrierConfigManager.CARRIER_NR_AVAILABILITY_NONE;
+
+ int[] nrAvailabilities = carrierConfig.getIntArray(
+ CarrierConfigManager.KEY_CARRIER_NR_AVAILABILITIES_INT_ARRAY);
+ mIsNrEnabledFromCarrierConfig = !ArrayUtils.isEmpty(nrAvailabilities);
return this;
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 9a4cb40..7eb53b9 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -202,7 +202,7 @@
super.onCreate(icicle);
final Context context = getContext();
- mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ mUserManager = context.getSystemService(UserManager.class);
mTelephonyManager = context.getSystemService(TelephonyManager.class)
.createForSubscriptionId(mSubId);
diff --git a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
index cfd587a..a4cff33 100644
--- a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
+++ b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
@@ -19,6 +19,7 @@
import static android.telephony.SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
import android.content.Context;
+import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.CellIdentity;
import android.telephony.CellIdentityGsm;
import android.telephony.CellIdentityLte;
@@ -180,7 +181,7 @@
public OperatorInfo getOperatorInfo() {
return new OperatorInfo(Objects.toString(mCellId.getOperatorAlphaLong(), ""),
Objects.toString(mCellId.getOperatorAlphaShort(), ""),
- getOperatorNumeric());
+ getOperatorNumeric(), getAccessNetworkTypeFromCellInfo(mCellInfo));
}
private int getIconIdForCell(CellInfo ci) {
@@ -225,6 +226,25 @@
return null;
}
+ private int getAccessNetworkTypeFromCellInfo(CellInfo ci) {
+ if (ci instanceof CellInfoGsm) {
+ return AccessNetworkType.GERAN;
+ }
+ if (ci instanceof CellInfoCdma) {
+ return AccessNetworkType.CDMA2000;
+ }
+ if ((ci instanceof CellInfoWcdma) || (ci instanceof CellInfoTdscdma)) {
+ return AccessNetworkType.UTRAN;
+ }
+ if (ci instanceof CellInfoLte) {
+ return AccessNetworkType.EUTRAN;
+ }
+ if (ci instanceof CellInfoNr) {
+ return AccessNetworkType.NGRAN;
+ }
+ return AccessNetworkType.UNKNOWN;
+ }
+
private void updateIcon(int level) {
if (!mUseNewApi || level < 0 || level >= NUM_SIGNAL_STRENGTH_BINS) {
return;
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index c8121c4..588d828 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -106,8 +106,8 @@
.createForSubscriptionId(mSubId);
mNetworkScanHelper = new NetworkScanHelper(
mTelephonyManager, mCallback, mNetworkScanExecutor);
- PersistableBundle bundle = ((CarrierConfigManager) getContext().getSystemService(
- Context.CARRIER_CONFIG_SERVICE)).getConfigForSubId(mSubId);
+ PersistableBundle bundle = (getContext().getSystemService(
+ CarrierConfigManager.class)).getConfigForSubId(mSubId);
if (bundle != null) {
mShow4GForLTE = bundle.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
index c782b66..6cb627b 100644
--- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
@@ -212,8 +212,8 @@
@Override
public View getView(int position, View convertView, ViewGroup parent) {
- final LayoutInflater inflater = (LayoutInflater)
- mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ final LayoutInflater inflater =
+ mContext.getSystemService(LayoutInflater.class);
if (convertView == null) {
convertView = inflater.inflate(mItemResId, null);
diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java
index 42d98e0..0e47556 100644
--- a/src/com/android/settings/overlay/FeatureFactory.java
+++ b/src/com/android/settings/overlay/FeatureFactory.java
@@ -32,6 +32,7 @@
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
@@ -112,6 +113,12 @@
public abstract BatteryStatusFeatureProvider getBatteryStatusFeatureProvider(
Context context);
+ /**
+ * Get implementation for Battery Settings provider.
+ */
+ public abstract BatterySettingsFeatureProvider getBatterySettingsFeatureProvider(
+ Context context);
+
public abstract DashboardFeatureProvider getDashboardFeatureProvider(Context context);
public abstract DockUpdaterFeatureProvider getDockUpdaterFeatureProvider();
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java
index 46b263a..dc08547 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java
@@ -45,6 +45,8 @@
import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProviderImpl;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProviderImpl;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProviderImpl;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
@@ -86,6 +88,7 @@
private SuggestionFeatureProvider mSuggestionFeatureProvider;
private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
+ private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
private AssistGestureFeatureProvider mAssistGestureFeatureProvider;
private UserFeatureProvider mUserFeatureProvider;
private SlicesFeatureProvider mSlicesFeatureProvider;
@@ -130,6 +133,14 @@
}
@Override
+ public BatterySettingsFeatureProvider getBatterySettingsFeatureProvider(Context context) {
+ if (mBatterySettingsFeatureProvider == null) {
+ mBatterySettingsFeatureProvider = new BatterySettingsFeatureProviderImpl();
+ }
+ return mBatterySettingsFeatureProvider;
+ }
+
+ @Override
public DashboardFeatureProvider getDashboardFeatureProvider(Context context) {
if (mDashboardFeatureProvider == null) {
mDashboardFeatureProvider = new DashboardFeatureProviderImpl(
diff --git a/src/com/android/settings/privacy/ShowClipAccessNotificationPreferenceController.java b/src/com/android/settings/privacy/ShowClipAccessNotificationPreferenceController.java
new file mode 100644
index 0000000..4622431
--- /dev/null
+++ b/src/com/android/settings/privacy/ShowClipAccessNotificationPreferenceController.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.privacy;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * Controller for preference to toggle whether clipboard access notifications should be shown.
+ */
+public class ShowClipAccessNotificationPreferenceController extends TogglePreferenceController {
+
+ private static final String KEY_SHOW_CLIP_ACCESS_NOTIFICATION = "show_clip_access_notification";
+
+ public ShowClipAccessNotificationPreferenceController(Context context) {
+ super(context, KEY_SHOW_CLIP_ACCESS_NOTIFICATION);
+ }
+
+ @Override
+ public boolean isChecked() {
+ // TODO(b/182349993) Retrieve default value from DeviceConfig.
+ return Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.CLIPBOARD_SHOW_ACCESS_NOTIFICATIONS, 1) != 0;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.CLIPBOARD_SHOW_ACCESS_NOTIFICATIONS, isChecked ? 1 : 0);
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+}
diff --git a/src/com/android/settings/security/ScreenPinningSettings.java b/src/com/android/settings/security/ScreenPinningSettings.java
index a8cb1c9..3fa098b 100644
--- a/src/com/android/settings/security/ScreenPinningSettings.java
+++ b/src/com/android/settings/security/ScreenPinningSettings.java
@@ -215,7 +215,7 @@
private void updateDisplay() {
if (isLockToAppEnabled(getActivity())) {
- mUseScreenLock.setVisible(true);
+ mUseScreenLock.setEnabled(true);
mUseScreenLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -226,7 +226,7 @@
mUseScreenLock.setTitle(getCurrentSecurityTitle());
} else {
mFooterPreference.setSummary(getAppPinningContent());
- mUseScreenLock.setVisible(false);
+ mUseScreenLock.setEnabled(false);
}
}
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 7dab4c0..3051b92 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -104,8 +104,8 @@
subId = SubscriptionManager.getDefaultSmsSubscriptionId();
}
- SubscriptionManager subscriptionManager = ((SubscriptionManager) context.getSystemService(
- Context.TELEPHONY_SUBSCRIPTION_SERVICE));
+ SubscriptionManager subscriptionManager = (context.getSystemService(
+ SubscriptionManager.class));
if (!subscriptionManager.isActiveSubscriptionId(subId)) {
Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
return;
@@ -130,8 +130,8 @@
return;
}
- TelephonyManager tm = ((TelephonyManager) context.getSystemService(
- Context.TELEPHONY_SERVICE)).createForSubscriptionId(subId);
+ TelephonyManager tm = (context.getSystemService(
+ TelephonyManager.class)).createForSubscriptionId(subId);
if (tm.isDataEnabledForApn(TYPE_MMS)) {
Log.w(TAG, "onEnableMmsDataRequest MMS data already enabled on sub ID " + subId);
@@ -230,14 +230,14 @@
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
- (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ context.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(notificationChannel);
notificationManager.notify(SIM_SELECT_NOTIFICATION_ID, builder.build());
}
public static void cancelSimSelectNotification(Context context) {
NotificationManager notificationManager =
- (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ context.getSystemService(NotificationManager.class);
notificationManager.cancel(SIM_SELECT_NOTIFICATION_ID);
}
@@ -270,14 +270,14 @@
// Notify the notification.
NotificationManager notificationManager =
- (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ context.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(notificationChannel);
notificationManager.notify(ENABLE_MMS_NOTIFICATION_ID, builder.build());
}
private void cancelEnableMmsNotification(Context context) {
NotificationManager notificationManager =
- (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ context.getSystemService(NotificationManager.class);
notificationManager.cancel(ENABLE_MMS_NOTIFICATION_ID);
}
diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java
index 53d9849..a9ddf95 100644
--- a/src/com/android/settings/users/UserDetailsSettings.java
+++ b/src/com/android/settings/users/UserDetailsSettings.java
@@ -290,6 +290,9 @@
@VisibleForTesting
void switchUser() {
try {
+ if (mUserInfo.isGuest()) {
+ mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_SWITCH_TO_GUEST);
+ }
ActivityManager.getService().switchUser(mUserInfo.id);
} catch (RemoteException re) {
Log.e(TAG, "Error while switching to other user.");
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 8010f41..6e82aab 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -820,6 +820,8 @@
*/
private void exitGuest() {
// Just to be safe
+ mMetricsFeatureProvider.action(getActivity(),
+ SettingsEnums.ACTION_USER_GUEST_EXIT_CONFIRMED);
if (!isCurrentUserGuest()) {
return;
}
@@ -1077,6 +1079,7 @@
return true;
} else if (pref == mAddGuest) {
mAddGuest.setEnabled(false); // prevent multiple tap issue
+ mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_USER_GUEST_ADD);
UserInfo guest = mUserManager.createGuest(
getContext(), getString(com.android.settingslib.R.string.user_guest));
openUserDetails(guest, true);
diff --git a/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java b/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java
index e8eab68..dee5817 100644
--- a/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java
+++ b/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java
@@ -16,8 +16,6 @@
package com.android.settings.utils;
-import android.os.Process;
-import android.security.keystore.AndroidKeyStoreProvider;
import android.security.keystore.KeyProperties;
import android.security.keystore2.AndroidKeyStoreLoadStoreParameter;
import android.util.Log;
@@ -41,6 +39,8 @@
public class AndroidKeystoreAliasLoader {
private static final String TAG = "SettingsKeystoreUtils";
+ private static final String KEYSTORE_PROVIDER = "AndroidKeyStore";
+
private final Collection<String> mKeyCertAliases;
private final Collection<String> mCaCertAliases;
/**
@@ -58,21 +58,13 @@
public AndroidKeystoreAliasLoader(Integer namespace) {
mKeyCertAliases = new ArrayList<>();
mCaCertAliases = new ArrayList<>();
- KeyStore keyStore = null;
+ final KeyStore keyStore;
final Enumeration<String> aliases;
try {
+ keyStore = KeyStore.getInstance(KEYSTORE_PROVIDER);
if (namespace != null && namespace != KeyProperties.NAMESPACE_APPLICATION) {
- if (AndroidKeyStoreProvider.isKeystore2Enabled()) {
- keyStore = KeyStore.getInstance("AndroidKeyStore");
- keyStore.load(new AndroidKeyStoreLoadStoreParameter(namespace));
- } else {
- // In the legacy case we pass in the WIFI UID because that is the only
- // possible special namespace that existed as of this writing,
- // and new namespaces must only be added using the new mechanism.
- keyStore = AndroidKeyStoreProvider.getKeyStoreForUid(Process.WIFI_UID);
- }
+ keyStore.load(new AndroidKeyStoreLoadStoreParameter(namespace));
} else {
- keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null);
}
aliases = keyStore.aliases();
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index 0543fee..4543f3f 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -319,7 +319,7 @@
@VisibleForTesting
static boolean appHasVpnPermission(Context context, @NonNull ApplicationInfo application) {
final AppOpsManager service =
- (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
+ context.getSystemService(AppOpsManager.class);
final List<AppOpsManager.PackageOps> ops = service.getOpsForPackage(application.uid,
application.packageName, new int[]{OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
return !ArrayUtils.isEmpty(ops);
diff --git a/src/com/android/settings/vpn2/ConfigDialog.java b/src/com/android/settings/vpn2/ConfigDialog.java
index 03e3613..24fb576 100644
--- a/src/com/android/settings/vpn2/ConfigDialog.java
+++ b/src/com/android/settings/vpn2/ConfigDialog.java
@@ -204,10 +204,16 @@
configureAdvancedOptionsVisibility();
- // Create a button to forget the profile if it has already been saved..
if (mExists) {
+ // Create a button to forget the profile if it has already been saved..
setButton(DialogInterface.BUTTON_NEUTRAL,
context.getString(R.string.vpn_forget), mListener);
+
+ // Display warning subtitle if the existing VPN is an insecure type...
+ if (VpnProfile.isLegacyType(mProfile.type)) {
+ TextView subtitle = mView.findViewById(R.id.dialog_alert_subtitle);
+ subtitle.setVisibility(View.VISIBLE);
+ }
}
// Create a button to save the profile.
diff --git a/src/com/android/settings/vpn2/ManageablePreference.java b/src/com/android/settings/vpn2/ManageablePreference.java
index 68971f2..c65073f 100644
--- a/src/com/android/settings/vpn2/ManageablePreference.java
+++ b/src/com/android/settings/vpn2/ManageablePreference.java
@@ -16,15 +16,20 @@
package com.android.settings.vpn2;
+import static android.text.Spanned.SPAN_EXCLUSIVE_INCLUSIVE;
+
import android.content.Context;
import android.content.res.Resources;
import android.os.UserHandle;
import android.os.UserManager;
+import android.text.SpannableString;
import android.text.TextUtils;
+import android.text.style.ForegroundColorSpan;
import android.util.AttributeSet;
import com.android.settings.R;
import com.android.settings.widget.GearPreference;
+import com.android.settingslib.Utils;
/**
* This class sets appropriate enabled state and user admin message when userId is set
@@ -34,6 +39,7 @@
public static int STATE_NONE = -1;
boolean mIsAlwaysOn = false;
+ boolean mIsInsecureVpn = false;
int mState = STATE_NONE;
int mUserId;
@@ -57,6 +63,10 @@
return mIsAlwaysOn;
}
+ public boolean isInsecureVpn() {
+ return mIsInsecureVpn;
+ }
+
public int getState() {
return mState;
}
@@ -77,8 +87,19 @@
}
/**
+ * Set whether the VPN associated with this preference has an insecure type.
+ * By default the value will be False.
+ */
+ public void setInsecureVpn(boolean isInsecureVpn) {
+ if (mIsInsecureVpn != isInsecureVpn) {
+ mIsInsecureVpn = isInsecureVpn;
+ updateSummary();
+ }
+ }
+
+ /**
* Update the preference summary string (see {@see Preference#setSummary}) with a string
- * reflecting connection status and always-on setting.
+ * reflecting connection status, always-on setting and whether the vpn is insecure.
*
* State is not shown for {@code STATE_NONE}.
*/
@@ -91,6 +112,18 @@
summary = TextUtils.isEmpty(summary) ? alwaysOnString : res.getString(
R.string.join_two_unrelated_items, summary, alwaysOnString);
}
- setSummary(summary);
+ if (mIsInsecureVpn) {
+ final String insecureString = res.getString(R.string.vpn_insecure_summary);
+ summary = TextUtils.isEmpty(summary) ? insecureString : res.getString(
+ R.string.join_two_unrelated_items, summary, insecureString);
+
+ SpannableString summarySpan = new SpannableString(summary);
+ final int colorError = Utils.getColorErrorDefaultColor(getContext());
+ summarySpan.setSpan(new ForegroundColorSpan(colorError), 0, summary.length(),
+ SPAN_EXCLUSIVE_INCLUSIVE);
+ setSummary(summarySpan);
+ } else {
+ setSummary(summary);
+ }
}
}
diff --git a/src/com/android/settings/vpn2/OWNERS b/src/com/android/settings/vpn2/OWNERS
index 0419e24..894d604 100644
--- a/src/com/android/settings/vpn2/OWNERS
+++ b/src/com/android/settings/vpn2/OWNERS
@@ -4,6 +4,7 @@
maze@google.com
reminv@google.com
xiaom@google.com
+goldmanj@google.com
# Emergency approvers in case the above are not available
satk@google.com
diff --git a/src/com/android/settings/vpn2/VpnInfoPreference.java b/src/com/android/settings/vpn2/VpnInfoPreference.java
new file mode 100644
index 0000000..cca45b5
--- /dev/null
+++ b/src/com/android/settings/vpn2/VpnInfoPreference.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.vpn2;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.View;
+
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.R;
+import com.android.settingslib.HelpUtils;
+import com.android.settingslib.RestrictedPreference;
+
+
+/**
+ * A preference with an Info icon on the side
+ */
+public class VpnInfoPreference extends RestrictedPreference implements View.OnClickListener {
+
+ private boolean mIsInsecureVpn = false;
+ private String mHelpUrl;
+
+ public VpnInfoPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mHelpUrl = context.getString(R.string.help_url_insecure_vpn);
+ }
+
+ @Override
+ protected int getSecondTargetResId() {
+ // Note: in the future, we will probably want to provide a configuration option
+ // for this info to not be the warning color.
+ return R.layout.preference_widget_warning;
+ }
+
+ @Override
+ protected boolean shouldHideSecondTarget() {
+ return false;
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+ final View icon = holder.findViewById(R.id.warning_button);
+ if (mIsInsecureVpn && !TextUtils.isEmpty(mHelpUrl)) {
+ icon.setVisibility(View.VISIBLE);
+ icon.setOnClickListener(this);
+ icon.setEnabled(true);
+ } else {
+ icon.setVisibility(View.GONE);
+ icon.setOnClickListener(this);
+ icon.setEnabled(false);
+ }
+
+ // Hide the divider from view
+ final View divider = holder.findViewById(R.id.two_target_divider);
+ divider.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.warning_button) {
+ final Intent intent = HelpUtils.getHelpIntent(
+ getContext(), mHelpUrl, this.getClass().getName());
+
+ if (intent != null) {
+ ((Activity) getContext()).startActivityForResult(intent, 0);
+ }
+ }
+ }
+
+ /**
+ * Sets whether this preference corresponds to an insecure VPN. This will also affect whether
+ * the warning icon appears to the user.
+ */
+ public void setInsecureVpn(boolean isInsecureVpn) {
+ if (mIsInsecureVpn != isInsecureVpn) {
+ mIsInsecureVpn = isInsecureVpn;
+ notifyChanged();
+ }
+ }
+}
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 7635733..2620426 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -116,9 +116,9 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
- mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- mVpnManager = (VpnManager) getSystemService(Context.VPN_MANAGEMENT_SERVICE);
+ mUserManager = getSystemService(UserManager.class);
+ mConnectivityManager = getSystemService(ConnectivityManager.class);
+ mVpnManager = getSystemService(VpnManager.class);
mUnavailable = isUiRestricted();
setHasOptionsMenu(!mUnavailable);
@@ -294,6 +294,7 @@
p.setState(LegacyVpnPreference.STATE_NONE);
}
p.setAlwaysOn(lockdownVpnKey != null && lockdownVpnKey.equals(profile.key));
+ p.setInsecureVpn(VpnProfile.isLegacyType(profile.type));
updates.add(p);
}
@@ -303,6 +304,7 @@
LegacyVpnPreference p = mSettings.findOrCreatePreference(stubProfile, false);
p.setState(vpn.state);
p.setAlwaysOn(lockdownVpnKey != null && lockdownVpnKey.equals(vpn.key));
+ p.setInsecureVpn(VpnProfile.isLegacyType(stubProfile.type));
updates.add(p);
}
@@ -509,7 +511,7 @@
}
// Fetch VPN-enabled apps from AppOps.
- AppOpsManager aom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
+ AppOpsManager aom = context.getSystemService(AppOpsManager.class);
List<AppOpsManager.PackageOps> apps =
aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
if (apps != null) {
diff --git a/src/com/android/settings/widget/CheckableRelativeLayout.java b/src/com/android/settings/widget/CheckableRelativeLayout.java
new file mode 100644
index 0000000..d26c042
--- /dev/null
+++ b/src/com/android/settings/widget/CheckableRelativeLayout.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityNodeInfo;
+import android.widget.Checkable;
+import android.widget.RelativeLayout;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+/**
+ * A RelativeLayout which implements {@link Checkable}. With this implementation, it could be used
+ * in the list item layout for {@link android.widget.AbsListView} to change UI after item click.
+ * Its checked state would be propagated to the checkable child.
+ *
+ * <p>
+ * To support accessibility, the state description is from the checkable view and is
+ * changed with {@link #setChecked(boolean)}. We make the checkable child unclickable, unfocusable
+ * and non-important for accessibility, so that the announcement wouldn't include
+ * the checkable view.
+ * <
+ */
+public class CheckableRelativeLayout extends RelativeLayout implements Checkable {
+
+ private Checkable mCheckable;
+ private View mCheckableChild;
+ private boolean mChecked;
+
+ public CheckableRelativeLayout(Context context) {
+ super(context);
+ }
+
+ public CheckableRelativeLayout(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ mCheckableChild = findFirstCheckableView(this);
+ if (mCheckableChild != null) {
+ mCheckableChild.setClickable(false);
+ mCheckableChild.setFocusable(false);
+ mCheckableChild.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
+ mCheckable = (Checkable) mCheckableChild;
+ mCheckable.setChecked(isChecked());
+ setStateDescriptionIfNeeded();
+ }
+ super.onFinishInflate();
+ }
+
+ @Nullable
+ private static View findFirstCheckableView(@NonNull ViewGroup viewGroup) {
+ final int childCount = viewGroup.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ final View child = viewGroup.getChildAt(i);
+ if (child instanceof Checkable) {
+ return child;
+ }
+ if (child instanceof ViewGroup) {
+ findFirstCheckableView((ViewGroup) child);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void setChecked(boolean checked) {
+ if (mChecked != checked) {
+ mChecked = checked;
+ if (mCheckable != null) {
+ mCheckable.setChecked(checked);
+ }
+ }
+ setStateDescriptionIfNeeded();
+ notifyViewAccessibilityStateChangedIfNeeded(
+ AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
+ }
+
+ private void setStateDescriptionIfNeeded() {
+ if (mCheckableChild == null) {
+ return;
+ }
+ setStateDescription(mCheckableChild.getStateDescription());
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mChecked;
+ }
+
+ @Override
+ public void toggle() {
+ setChecked(!mChecked);
+ }
+
+ @Override
+ public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
+ super.onInitializeAccessibilityEvent(event);
+ event.setChecked(mChecked);
+ }
+
+ @Override
+ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(info);
+ info.setChecked(mChecked);
+ }
+}
diff --git a/src/com/android/settings/wifi/ChangeWifiStateDetails.java b/src/com/android/settings/wifi/ChangeWifiStateDetails.java
index 9841615..4e3e62e 100644
--- a/src/com/android/settings/wifi/ChangeWifiStateDetails.java
+++ b/src/com/android/settings/wifi/ChangeWifiStateDetails.java
@@ -49,7 +49,7 @@
super.onCreate(savedInstanceState);
final Context context = getActivity();
mAppBridge = new AppStateChangeWifiStateBridge(context, mState, null);
- mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
+ mAppOpsManager = context.getSystemService(AppOpsManager.class);
// find preferences
addPreferencesFromResource(R.xml.change_wifi_state_details);
diff --git a/src/com/android/settings/wifi/ConfigureWifiSettings.java b/src/com/android/settings/wifi/ConfigureWifiSettings.java
index ff313c7..484d3cc 100644
--- a/src/com/android/settings/wifi/ConfigureWifiSettings.java
+++ b/src/com/android/settings/wifi/ConfigureWifiSettings.java
@@ -69,7 +69,7 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
+ final WifiManager wifiManager = getSystemService(WifiManager.class);
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new WifiP2pPreferenceController(context, getSettingsLifecycle(),
wifiManager));
diff --git a/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java b/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java
index 44114e5..5fa4dfb 100644
--- a/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java
+++ b/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java
@@ -51,7 +51,7 @@
super(context, KEY_USE_OPEN_WIFI_AUTOMATICALLY);
mContentResolver = context.getContentResolver();
mNetworkScoreManager =
- (NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
+ context.getSystemService(NetworkScoreManager.class);
mSettingObserver = new SettingObserver();
updateEnableUseWifiComponentName();
checkForFeatureSupportedScorers();
diff --git a/src/com/android/settings/wifi/WifiAPITest.java b/src/com/android/settings/wifi/WifiAPITest.java
index 15465ed..498539d 100644
--- a/src/com/android/settings/wifi/WifiAPITest.java
+++ b/src/com/android/settings/wifi/WifiAPITest.java
@@ -64,7 +64,7 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
+ mWifiManager = getSystemService(WifiManager.class);
}
@Override
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index db355f4..408ffbe 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -812,9 +812,12 @@
.get(mEapSimSpinner.getSelectedItemPosition()).getCarrierId();
}
- config.setIpConfiguration(
- new IpConfiguration(mIpAssignment, mProxySettings,
- mStaticIpConfiguration, mHttpProxy));
+ final IpConfiguration ipConfig = new IpConfiguration();
+ ipConfig.setIpAssignment(mIpAssignment);
+ ipConfig.setProxySettings(mProxySettings);
+ ipConfig.setStaticIpConfiguration(mStaticIpConfiguration);
+ ipConfig.setHttpProxy(mHttpProxy);
+ config.setIpConfiguration(ipConfig);
if (mMeteredSettingsSpinner != null) {
config.meteredOverride = mMeteredSettingsSpinner.getSelectedItemPosition();
}
@@ -1382,18 +1385,18 @@
StaticIpConfiguration staticConfig = config.getIpConfiguration()
.getStaticIpConfiguration();
if (staticConfig != null) {
- if (staticConfig.ipAddress != null) {
+ if (staticConfig.getIpAddress() != null) {
mIpAddressView.setText(
- staticConfig.ipAddress.getAddress().getHostAddress());
- mNetworkPrefixLengthView.setText(Integer.toString(staticConfig.ipAddress
- .getPrefixLength()));
+ staticConfig.getIpAddress().getAddress().getHostAddress());
+ mNetworkPrefixLengthView.setText(Integer.toString(
+ staticConfig.getIpAddress().getPrefixLength()));
}
- if (staticConfig.gateway != null) {
- mGatewayView.setText(staticConfig.gateway.getHostAddress());
+ if (staticConfig.getGateway() != null) {
+ mGatewayView.setText(staticConfig.getGateway().getHostAddress());
}
- Iterator<InetAddress> dnsIterator = staticConfig.dnsServers.iterator();
+ Iterator<InetAddress> dnsIterator = staticConfig.getDnsServers().iterator();
if (dnsIterator.hasNext()) {
mDns1View.setText(dnsIterator.next().getHostAddress());
}
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 5cc0499..9f3b1a7 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -775,9 +775,12 @@
return null;
}
- config.setIpConfiguration(
- new IpConfiguration(mIpAssignment, mProxySettings,
- mStaticIpConfiguration, mHttpProxy));
+ final IpConfiguration ipConfig = new IpConfiguration();
+ ipConfig.setIpAssignment(mIpAssignment);
+ ipConfig.setProxySettings(mProxySettings);
+ ipConfig.setStaticIpConfiguration(mStaticIpConfiguration);
+ ipConfig.setHttpProxy(mHttpProxy);
+ config.setIpConfiguration(ipConfig);
if (mMeteredSettingsSpinner != null) {
config.meteredOverride = mMeteredSettingsSpinner.getSelectedItemPosition();
}
@@ -920,7 +923,7 @@
return R.string.wifi_ip_settings_invalid_dns;
}
dnsServers.add(dnsAddr);
- staticIpConfiguration.dnsServers.add(dnsAddr);
+ staticIpConfiguration.getDnsServers().add(dnsAddr);
}
if (mDns2View.length() > 0) {
@@ -930,7 +933,7 @@
return R.string.wifi_ip_settings_invalid_dns;
}
dnsServers.add(dnsAddr);
- staticIpConfiguration.dnsServers.add(dnsAddr);
+ staticIpConfiguration.getDnsServers().add(dnsAddr);
}
staticIPBuilder.setDnsServers(dnsServers);
return 0;
@@ -1356,7 +1359,7 @@
staticConfig.getIpAddress().getPrefixLength()));
}
- if (staticConfig.gateway != null) {
+ if (staticConfig.getGateway() != null) {
mGatewayView.setText(staticConfig.getGateway().getHostAddress());
}
diff --git a/src/com/android/settings/wifi/WifiConfigInfo.java b/src/com/android/settings/wifi/WifiConfigInfo.java
index 0de3063..18ac2e5 100644
--- a/src/com/android/settings/wifi/WifiConfigInfo.java
+++ b/src/com/android/settings/wifi/WifiConfigInfo.java
@@ -38,7 +38,7 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
+ mWifiManager = getSystemService(WifiManager.class);
setContentView(R.layout.wifi_config_info);
mConfigList = (TextView) findViewById(R.id.config_list);
}
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index dc5be42..ba1ee3c 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -75,7 +75,7 @@
public WifiEnabler(Context context, SwitchWidgetController switchWidget,
MetricsFeatureProvider metricsFeatureProvider) {
this(context, switchWidget, metricsFeatureProvider,
- (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
+ context.getSystemService(ConnectivityManager.class));
}
@VisibleForTesting
@@ -86,7 +86,7 @@
mSwitchWidget = switchWidget;
mSwitchWidget.setListener(this);
mMetricsFeatureProvider = metricsFeatureProvider;
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ mWifiManager = context.getSystemService(WifiManager.class);
mConnectivityManager = connectivityManager;
mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
diff --git a/src/com/android/settings/wifi/WifiNoInternetDialog.java b/src/com/android/settings/wifi/WifiNoInternetDialog.java
index 9d90b6a..3cd8a8a 100644
--- a/src/com/android/settings/wifi/WifiNoInternetDialog.java
+++ b/src/com/android/settings/wifi/WifiNoInternetDialog.java
@@ -70,22 +70,17 @@
super.onCreate(savedInstanceState);
final Intent intent = getIntent();
- if (intent == null || !isKnownAction(intent) || !"netId".equals(intent.getScheme())) {
+ if (intent == null || !isKnownAction(intent)) {
Log.e(TAG, "Unexpected intent " + intent + ", exiting");
finish();
return;
}
mAction = intent.getAction();
-
- try {
- mNetwork = new Network(Integer.parseInt(intent.getData().getSchemeSpecificPart()));
- } catch (NullPointerException|NumberFormatException e) {
- mNetwork = null;
- }
+ mNetwork = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
if (mNetwork == null) {
- Log.e(TAG, "Can't determine network from '" + intent.getData() + "' , exiting");
+ Log.e(TAG, "Can't determine network from intent extra, exiting");
finish();
return;
}
@@ -112,7 +107,7 @@
}
};
- mCM = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+ mCM = getSystemService(ConnectivityManager.class);
mCM.registerNetworkCallback(request, mNetworkCallback);
final NetworkInfo ni = mCM.getNetworkInfo(mNetwork);
diff --git a/src/com/android/settings/wifi/WifiStatusTest.java b/src/com/android/settings/wifi/WifiStatusTest.java
index 249cd71..06242e3 100644
--- a/src/com/android/settings/wifi/WifiStatusTest.java
+++ b/src/com/android/settings/wifi/WifiStatusTest.java
@@ -116,7 +116,7 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
+ mWifiManager = getSystemService(WifiManager.class);
mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
diff --git a/src/com/android/settings/wifi/WifiUtils.java b/src/com/android/settings/wifi/WifiUtils.java
index d05260a..e576851 100644
--- a/src/com/android/settings/wifi/WifiUtils.java
+++ b/src/com/android/settings/wifi/WifiUtils.java
@@ -83,7 +83,7 @@
final DevicePolicyManager dpm =
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
final PackageManager pm = context.getPackageManager();
- final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ final UserManager um = context.getSystemService(UserManager.class);
// Check if device has DPM capability. If it has and dpm is still null, then we
// treat this case with suspicion and bail out.
diff --git a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
index 5869705..3aa62b9 100644
--- a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
@@ -26,7 +26,6 @@
import android.location.LocationManager;
import android.net.wifi.WifiManager;
import android.provider.Settings;
-import android.util.FeatureFlagUtils;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
@@ -45,7 +44,6 @@
* {@link TogglePreferenceController} that controls whether the Wi-Fi Wakeup feature should be
* enabled.
*/
-// TODO(b/167474581): Should clean up this controller when Provider Model finished.
public class WifiWakeupPreferenceController extends TogglePreferenceController implements
LifecycleObserver, OnPause, OnResume {
@@ -75,7 +73,7 @@
public WifiWakeupPreferenceController(Context context) {
super(context, KEY_ENABLE_WIFI_WAKEUP);
- mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
+ mLocationManager = context.getSystemService(LocationManager.class);
mWifiManager = context.getSystemService(WifiManager.class);
}
@@ -91,9 +89,6 @@
@Override
public int getAvailabilityStatus() {
- if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
- return CONDITIONALLY_UNAVAILABLE;
- }
return AVAILABLE;
}
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index de64b91..3cfe514 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -128,8 +128,8 @@
boolean isWfcModeEditable = true;
boolean isWfcRoamingModeEditable = false;
- final CarrierConfigManager configManager = (CarrierConfigManager)
- activity.getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ final CarrierConfigManager configManager =
+ activity.getSystemService(CarrierConfigManager.class);
if (configManager != null) {
PersistableBundle b =
configManager.getConfigForSubId(WifiCallingSettingsForSub.this.mSubId);
@@ -343,8 +343,8 @@
return;
}
- final CarrierConfigManager configManager = (CarrierConfigManager)
- getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ final CarrierConfigManager configManager =
+ getSystemService(CarrierConfigManager.class);
boolean isWifiOnlySupported = true;
if (configManager != null) {
diff --git a/src/com/android/settings/wifi/details2/AddDevicePreferenceController2.java b/src/com/android/settings/wifi/details2/AddDevicePreferenceController2.java
index 8f9741a..9ab64c7 100644
--- a/src/com/android/settings/wifi/details2/AddDevicePreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/AddDevicePreferenceController2.java
@@ -42,7 +42,7 @@
public AddDevicePreferenceController2(Context context) {
super(context, KEY_ADD_DEVICE);
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ mWifiManager = context.getSystemService(WifiManager.class);
}
public void setWifiEntry(WifiEntry wifiEntry) {
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index 2d9d444..211ceed 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -844,7 +844,8 @@
// Find IPv4 default gateway.
String gateway = null;
for (RouteInfo routeInfo : mLinkProperties.getRoutes()) {
- if (routeInfo.isIPv4Default() && routeInfo.hasGateway()) {
+ if (routeInfo.hasGateway() && routeInfo.isDefaultRoute()
+ && routeInfo.getDestination().getAddress() instanceof Inet4Address) {
gateway = routeInfo.getGateway().getHostAddress();
break;
}
diff --git a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
index b154a9b..488ffcb 100644
--- a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
+++ b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
@@ -75,7 +75,8 @@
// Interval between initiating SavedNetworkTracker scans
private static final long SCAN_INTERVAL_MILLIS = 10_000;
- private NetworkDetailsTracker mNetworkDetailsTracker;
+ @VisibleForTesting
+ NetworkDetailsTracker mNetworkDetailsTracker;
private HandlerThread mWorkerThread;
private WifiDetailPreferenceController2 mWifiDetailPreferenceController2;
private List<WifiDialog2.WifiDialog2Listener> mWifiDialogListeners = new ArrayList<>();
@@ -125,9 +126,11 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- MenuItem item = menu.add(0, Menu.FIRST, 0, R.string.wifi_modify);
- item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
- item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+ if (isEditable()) {
+ MenuItem item = menu.add(0, Menu.FIRST, 0, R.string.wifi_modify);
+ item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
+ item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+ }
super.onCreateOptionsMenu(menu, inflater);
}
@@ -140,8 +143,8 @@
if (admin == null) {
final DevicePolicyManager dpm = (DevicePolicyManager)
getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
- final UserManager um = (UserManager)
- getContext().getSystemService(Context.USER_SERVICE);
+ final UserManager um =
+ getContext().getSystemService(UserManager.class);
final int profileOwnerUserId = Utils.getManagedProfileId(
um, UserHandle.myUserId());
if (profileOwnerUserId != UserHandle.USER_NULL) {
@@ -252,6 +255,17 @@
getArguments().getString(KEY_CHOSEN_WIFIENTRY_KEY));
}
+ private boolean isEditable() {
+ if (mNetworkDetailsTracker == null) {
+ return false;
+ }
+ final WifiEntry wifiEntry = mNetworkDetailsTracker.getWifiEntry();
+ if (wifiEntry == null) {
+ return false;
+ }
+ return wifiEntry.isSaved();
+ }
+
/**
* API call for refreshing the preferences in this fragment.
*/
diff --git a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
index c484922..72a2361 100644
--- a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
@@ -45,7 +45,7 @@
public WifiPrivacyPreferenceController2(Context context) {
super(context, KEY_WIFI_PRIVACY);
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ mWifiManager = context.getSystemService(WifiManager.class);
}
public void setWifiEntry(WifiEntry wifiEntry) {
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index abf5bec..081e160 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -373,8 +373,8 @@
* device security or if lock screen is unlocked
*/
public static void showLockScreen(Context context, Runnable successRunnable) {
- final KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(
- Context.KEYGUARD_SERVICE);
+ final KeyguardManager keyguardManager = context.getSystemService(
+ KeyguardManager.class);
if (keyguardManager.isKeyguardSecure()) {
final BiometricPrompt.AuthenticationCallback authenticationCallback =
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java b/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java
index 9604410..8696bef 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java
@@ -71,7 +71,7 @@
super(context);
mWifiManager = wifiManager;
lifecycle.addObserver(this);
- mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
+ mLocationManager = context.getSystemService(LocationManager.class);
}
@Override
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
index 9578c80..0aac0bb 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
@@ -200,7 +200,7 @@
public void onActivityCreated(Bundle savedInstanceState) {
final Activity activity = getActivity();
if (mWifiP2pManager == null) {
- mWifiP2pManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
+ mWifiP2pManager = getSystemService(WifiP2pManager.class);
}
if (mWifiP2pManager != null) {
diff --git a/src/com/android/settings/wifi/qrcode/QrCamera.java b/src/com/android/settings/wifi/qrcode/QrCamera.java
index 3865eb1..274655d 100644
--- a/src/com/android/settings/wifi/qrcode/QrCamera.java
+++ b/src/com/android/settings/wifi/qrcode/QrCamera.java
@@ -202,7 +202,7 @@
}
final WindowManager winManager =
- (WindowManager) mContext.get().getSystemService(Context.WINDOW_SERVICE);
+ mContext.get().getSystemService(WindowManager.class);
final int rotation = winManager.getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
diff --git a/src/com/android/settings/wifi/tether/TetherService.java b/src/com/android/settings/wifi/tether/TetherService.java
index 5902719..a3321bb 100644
--- a/src/com/android/settings/wifi/tether/TetherService.java
+++ b/src/com/android/settings/wifi/tether/TetherService.java
@@ -255,7 +255,7 @@
}
private void disableTethering(final int tetheringType) {
- final TetheringManager tm = (TetheringManager) getSystemService(Context.TETHERING_SERVICE);
+ final TetheringManager tm = getSystemService(TetheringManager.class);
tm.stopTethering(tetheringType);
}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherBasePreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherBasePreferenceController.java
index 46da097..a950dc3 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherBasePreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherBasePreferenceController.java
@@ -45,8 +45,8 @@
OnTetherConfigUpdateListener listener) {
super(context);
mListener = listener;
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- mTm = (TetheringManager) context.getSystemService(Context.TETHERING_SERVICE);
+ mWifiManager = context.getSystemService(WifiManager.class);
+ mTm = context.getSystemService(TetheringManager.class);
mWifiRegexs = mTm.getTetherableWifiRegexs();
}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
index 70b6a45..1fa41b2 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
@@ -63,7 +63,7 @@
boolean initSoftApManager) {
super(context);
mTetheringManager = context.getSystemService(TetheringManager.class);
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ mWifiManager = context.getSystemService(WifiManager.class);
mWifiRegexs = mTetheringManager.getTetherableWifiRegexs();
mLifecycle = lifecycle;
if (lifecycle != null) {
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSettings.java b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
index e342550..41b439b 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSettings.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
@@ -110,7 +110,7 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ mWifiManager = context.getSystemService(WifiManager.class);
mTetherChangeReceiver = new TetherChangeReceiver();
mSSIDPreferenceController = use(WifiTetherSSIDPreferenceController.class);
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java b/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java
index 3d8cd3e..379bf6d 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java
@@ -73,8 +73,8 @@
mSwitch = mSwitchBar.getSwitch();
mDataSaverBackend = new DataSaverBackend(context);
mConnectivityManager =
- (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ context.getSystemService(ConnectivityManager.class);
+ mWifiManager = context.getSystemService(WifiManager.class);
mSwitchBar.setChecked(mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED);
updateWifiSwitch();
}
diff --git a/tests/anomaly-tester/AndroidManifest.xml b/tests/anomaly-tester/AndroidManifest.xml
index d6f68a8..3c5fb1f 100644
--- a/tests/anomaly-tester/AndroidManifest.xml
+++ b/tests/anomaly-tester/AndroidManifest.xml
@@ -19,6 +19,8 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
@@ -49,4 +51,4 @@
android:label="Settings Test Cases">
</instrumentation>
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/tests/componenttests/AndroidManifest.xml b/tests/componenttests/AndroidManifest.xml
index 54ea374..fb6c26f 100644
--- a/tests/componenttests/AndroidManifest.xml
+++ b/tests/componenttests/AndroidManifest.xml
@@ -20,6 +20,8 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
@@ -37,4 +39,4 @@
android:label="Settings Test Cases">
</instrumentation>
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java b/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java
index 5ac5c66..6c5b9f2 100644
--- a/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java
@@ -57,7 +57,7 @@
ShadowSettings.setAirplaneMode(true);
- mAirplaneModeEnabler.mTelephonyCallback.onRadioPowerStateChanged(
+ mAirplaneModeEnabler.mPhoneStateListener.onRadioPowerStateChanged(
TelephonyManager.RADIO_POWER_OFF);
verify(mAirplaneModeChangedListener, times(1)).onAirplaneModeChanged(true);
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationSettingsFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationSettingsFragmentTest.java
index d49213c..11128e4 100644
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationSettingsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationSettingsFragmentTest.java
@@ -16,12 +16,15 @@
package com.android.settings.accessibility;
+import static com.android.settings.accessibility.MagnificationCapabilities.MagnificationMode;
import static com.android.settings.accessibility.MagnificationPreferenceFragment.ON;
+import static com.android.settings.accessibility.MagnificationSettingsFragment.MagnificationModeInfo;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -29,7 +32,8 @@
import android.content.Context;
import android.os.Bundle;
import android.provider.Settings;
-import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
@@ -77,7 +81,7 @@
}
@Test
- public void onCreateDialog_capabilitiesInBundle_matchCheckBoxStatus() {
+ public void onCreateDialog_capabilitiesInBundle_checkedModeInDialogIsExpected() {
final Bundle windowModeSavedInstanceState = new Bundle();
windowModeSavedInstanceState.putInt(EXTRA_CAPABILITY,
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW);
@@ -85,23 +89,21 @@
mFragment.onCreate(windowModeSavedInstanceState);
mFragment.onCreateDialog(MagnificationSettingsFragment.DIALOG_MAGNIFICATION_CAPABILITY);
- assertThat(mFragment.mMagnifyFullScreenCheckBox.isChecked()).isFalse();
- assertThat(mFragment.mMagnifyWindowCheckBox.isChecked()).isTrue();
+ assertThat(getChoseModeFromDialog()).isEqualTo(MagnificationMode.WINDOW);
}
@Test
- public void onCreateDialog_capabilitiesInSettings_matchCheckBoxStatus() {
+ public void onCreateDialog_capabilitiesInSetting_checkedModeInDialogIsExpected() {
MagnificationCapabilities.setCapabilities(mContext,
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN);
mFragment.onCreate(Bundle.EMPTY);
mFragment.onCreateDialog(MagnificationSettingsFragment.DIALOG_MAGNIFICATION_CAPABILITY);
- assertThat(mFragment.mMagnifyFullScreenCheckBox.isChecked()).isTrue();
- assertThat(mFragment.mMagnifyWindowCheckBox.isChecked()).isFalse();
+ assertThat(getChoseModeFromDialog()).isEqualTo(MagnificationMode.FULLSCREEN);
}
@Test
- public void onCreateDialog_capabilitiesInSettingsAndBundle_matchBundleValueCheckBoxStatus() {
+ public void onCreateDialog_choseModeIsDifferentFromInSettings_ShowUsersChoseModeInDialog() {
final Bundle allModeSavedInstanceState = new Bundle();
allModeSavedInstanceState.putInt(EXTRA_CAPABILITY,
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL);
@@ -111,37 +113,93 @@
mFragment.onCreate(allModeSavedInstanceState);
mFragment.onCreateDialog(MagnificationSettingsFragment.DIALOG_MAGNIFICATION_CAPABILITY);
- assertThat(mFragment.mMagnifyFullScreenCheckBox.isChecked()).isTrue();
- assertThat(mFragment.mMagnifyWindowCheckBox.isChecked()).isTrue();
+ assertThat(getChoseModeFromDialog()).isEqualTo(MagnificationMode.ALL);
}
@Test
- public void onCreateDialog_emptySettingsAndBundle_matchDefaultValueCheckBoxStatus() {
+ public void onCreateDialog_emptySettingsAndBundle_checkedModeInDialogIsDefaultValue() {
mFragment.onCreate(Bundle.EMPTY);
mFragment.onCreateDialog(MagnificationSettingsFragment.DIALOG_MAGNIFICATION_CAPABILITY);
- // Compare to default Capabilities
- assertThat(mFragment.mMagnifyFullScreenCheckBox.isChecked()).isTrue();
- assertThat(mFragment.mMagnifyWindowCheckBox.isChecked()).isFalse();
+ assertThat(getChoseModeFromDialog()).isEqualTo(MagnificationMode.FULLSCREEN);
}
@Test
- public void checkWindowModeCheckBox_tripleTapEnabled_showSwitchShortcutDialog() {
+ public void chooseWindowMode_tripleTapEnabled_showSwitchShortcutDialog() {
+ enableTripleTap();
final Bundle fullScreenModeSavedInstanceState = new Bundle();
fullScreenModeSavedInstanceState.putInt(EXTRA_CAPABILITY,
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN);
mFragment.onCreate(fullScreenModeSavedInstanceState);
mFragment.onCreateDialog(MagnificationSettingsFragment.DIALOG_MAGNIFICATION_CAPABILITY);
- enableTripleTap();
- final View dialogWidowView = mFragment.mDialog.findViewById(R.id.magnify_window_screen);
- final View dialogWindowTextArea = dialogWidowView.findViewById(R.id.container);
- dialogWindowTextArea.performClick();
+ performItemClickWith(MagnificationMode.WINDOW);
verify(mFragment).showDialog(
MagnificationSettingsFragment.DIALOG_MAGNIFICATION_SWITCH_SHORTCUT);
}
+ @Test
+ public void chooseModeAll_tripleTapEnabled_showSwitchShortcutDialog() {
+ enableTripleTap();
+ final Bundle fullScreenModeSavedInstanceState = new Bundle();
+ fullScreenModeSavedInstanceState.putInt(EXTRA_CAPABILITY,
+ Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN);
+ mFragment.onCreate(fullScreenModeSavedInstanceState);
+ mFragment.onCreateDialog(MagnificationSettingsFragment.DIALOG_MAGNIFICATION_CAPABILITY);
+
+ performItemClickWith(MagnificationMode.ALL);
+
+ verify(mFragment).showDialog(
+ MagnificationSettingsFragment.DIALOG_MAGNIFICATION_SWITCH_SHORTCUT);
+ }
+
+ @Test
+ public void chooseWindowMode_WindowModeInSettingsAndTripleTapEnabled_notShowShortCutDialog() {
+ enableTripleTap();
+ MagnificationCapabilities.setCapabilities(mContext,
+ Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW);
+ mFragment.onCreate(Bundle.EMPTY);
+ mFragment.onCreateDialog(MagnificationSettingsFragment.DIALOG_MAGNIFICATION_CAPABILITY);
+
+ performItemClickWith(MagnificationMode.WINDOW);
+
+ verify(mFragment, never()).showDialog(
+ MagnificationSettingsFragment.DIALOG_MAGNIFICATION_SWITCH_SHORTCUT);
+ }
+
+ private int getChoseModeFromDialog() {
+ final ListView listView = mFragment.mMagnificationModesListView;
+ assertThat(listView).isNotNull();
+
+ final int checkedPosition = listView.getCheckedItemPosition();
+ final MagnificationModeInfo modeInfo =
+ (MagnificationModeInfo) listView.getAdapter().getItem(
+ checkedPosition);
+ return modeInfo.mMagnificationMode;
+ }
+
+ private void performItemClickWith(@MagnificationMode int mode) {
+ final ListView listView = mFragment.mMagnificationModesListView;
+ assertThat(listView).isNotNull();
+
+ int modeIndex = AdapterView.NO_ID;
+ // Index 0 is header.
+ for (int i = 1; i < listView.getAdapter().getCount(); i++) {
+ final MagnificationModeInfo modeInfo =
+ (MagnificationModeInfo) listView.getAdapter().getItem(i);
+ if (modeInfo.mMagnificationMode == mode) {
+ modeIndex = i;
+ break;
+ }
+ }
+ if (modeIndex == AdapterView.NO_ID) {
+ throw new RuntimeException("The mode is not in the list.");
+ }
+
+ listView.performItemClick(listView.getChildAt(modeIndex), modeIndex, modeIndex);
+ }
+
private void enableTripleTap() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON);
diff --git a/tests/robotests/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceControllerTest.java
index 39a663e..01942f0 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ReduceBrightColorsPreferenceControllerTest.java
@@ -19,7 +19,6 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
-import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -32,29 +31,14 @@
@RunWith(AndroidJUnit4.class)
public class ReduceBrightColorsPreferenceControllerTest {
private static final String PREF_KEY = "rbc_preference";
- private static final String RBC_ACTIVATED =
- Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED;
- private static final int ON = 1;
- private static final int OFF = 0;
private final Context mContext = ApplicationProvider.getApplicationContext();
private final ReduceBrightColorsPreferenceController mController =
new ReduceBrightColorsPreferenceController(mContext, PREF_KEY);
@Test
- public void getSummary_enabledRbc_shouldReturnOnSummary() {
- Settings.Secure.putInt(mContext.getContentResolver(),
- RBC_ACTIVATED, ON);
-
+ public void getSummary_returnSummary() {
assertThat(mController.getSummary().toString().contains(
- mContext.getText(R.string.accessibility_feature_state_on))).isTrue();
- }
- @Test
- public void getSummary_disabledRbc_shouldReturnOffSummary() {
- Settings.Secure.putInt(mContext.getContentResolver(),
- RBC_ACTIVATED, OFF);
-
- assertThat(mController.getSummary().toString().contains(
- mContext.getText(R.string.accessibility_feature_state_off))).isTrue();
+ mContext.getText(R.string.reduce_bright_colors_preference_summary))).isTrue();
}
}
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index b22b156..4b6a6a8 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -39,6 +39,7 @@
import android.text.TextUtils;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
@@ -72,9 +73,13 @@
ShadowSettingsLibUtils.class})
public class AccountPreferenceControllerTest {
+ private static final String PREF_KEY_ACCOUNTS = "accounts_category";
+
@Mock(answer = RETURNS_DEEP_STUBS)
private PreferenceScreen mScreen;
@Mock(answer = RETURNS_DEEP_STUBS)
+ private PreferenceCategory mAccountsCategory;
+ @Mock(answer = RETURNS_DEEP_STUBS)
private UserManager mUserManager;
@Mock(answer = RETURNS_DEEP_STUBS)
private SettingsPreferenceFragment mFragment;
@@ -95,6 +100,9 @@
shadowApp.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
+ // This is a bit ugly, but hard to avoid because of how the mocks are used in these tests.
+ // TODO: Refactor these tests to not use RETURNS_DEEP_STUBS.
+ when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
.thenReturn(new AuthenticatorDescription[0]);
@@ -166,6 +174,7 @@
// First time resume will build the UI
mController.onResume();
reset(mScreen);
+ when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
mController.onResume();
verify(mScreen, never()).addPreference(any(PreferenceGroup.class));
@@ -184,6 +193,7 @@
// add a new profile
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
reset(mScreen);
+ when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
mController.onResume();
verify(mScreen, times(1)).addPreference(any(PreferenceGroup.class));
diff --git a/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
index 534d3c6..04db527 100644
--- a/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
@@ -27,7 +27,6 @@
import static org.mockito.Mockito.verify;
import android.accounts.Account;
-import android.app.ActivityManager;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
@@ -57,7 +56,6 @@
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowActivityManager;
import org.robolectric.shadows.ShadowContentResolver;
import org.robolectric.shadows.ShadowPackageManager;
@@ -97,31 +95,7 @@
}
@Test
- public void onStart_configDisabled_doNothing() {
- final AvatarViewMixin mixin = spy(new AvatarViewMixin(mActivity, mImageView));
- mixin.onStart();
-
- verify(mixin, never()).hasAccount();
- }
-
- @Test
- public void onStart_lowRamDevice_doNothing() {
- final AvatarViewMixin mixin = spy(new AvatarViewMixin(mActivity, mImageView));
-
- final ShadowActivityManager activityManager =
- Shadow.extract(mContext.getSystemService(ActivityManager.class));
- activityManager.setIsLowRamDevice(true);
-
- mixin.onStart();
-
- verify(mixin, never()).hasAccount();
- }
-
- @Test
- @Config(qualifiers = "mcc999",
- shadows = {
- BatteryFixSliceTest.ShadowBatteryTipLoader.class
- })
+ @Config(shadows = BatteryFixSliceTest.ShadowBatteryTipLoader.class)
public void onStart_useMockAvatarViewMixin_shouldBeExecuted() {
final AvatarViewMixin mockAvatar = spy(new AvatarViewMixin(mActivity, mImageView));
@@ -132,7 +106,6 @@
}
@Test
- @Config(qualifiers = "mcc999")
public void onStart_noAccount_mAccountNameShouldBeNull() {
final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(mActivity, mImageView);
avatarViewMixin.mAccountName = FAKE_ACCOUNT;
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/MediaManagementAppsDetailsTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/MediaManagementAppsDetailsTest.java
new file mode 100644
index 0000000..6297064
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/MediaManagementAppsDetailsTest.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.applications.AppStateAppOpsBridge;
+import com.android.settings.applications.AppStateMediaManagementAppsBridge;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class MediaManagementAppsDetailsTest {
+
+ @Mock
+ private SwitchPreference mSwitchPref;
+ @Mock
+ private PackageInfo mPackageInfo;
+ @Mock
+ private AppStateMediaManagementAppsBridge mAppStateBridge;
+ @Mock
+ private AppStateAppOpsBridge.PermissionState mPermissionState;
+
+ private MediaManagementAppsDetails mFragment = new MediaManagementAppsDetails();
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ ReflectionHelpers.setField(mFragment, "mSwitchPref", mSwitchPref);
+ ReflectionHelpers.setField(mFragment, "mAppBridge", mAppStateBridge);
+ }
+
+ @Test
+ public void refreshUi_noPackageInfo_returnFalse() {
+ assertThat(mFragment.refreshUi()).isFalse();
+ }
+
+ @Test
+ public void refreshUi_noApplicationInfo_returnFalse() {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+
+ assertThat(mFragment.refreshUi()).isFalse();
+ }
+
+ @Test
+ public void refreshUi_hasApplicationInfo_returnTrue() {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+ mPackageInfo.applicationInfo = new ApplicationInfo();
+ when(mAppStateBridge.createPermissionState(nullable(String.class), anyInt()))
+ .thenReturn(mPermissionState);
+
+ assertThat(mFragment.refreshUi()).isTrue();
+ }
+
+ @Test
+ public void refreshUi_permissionDeclaredFalse_switchPreferenceUnEnabled() {
+ assert_refreshUi_switchPreferenceSetEnabled(false /* isPermissionDeclared */);
+ }
+
+ @Test
+ public void refreshUi_permissionDeclaredTrue_switchPreferenceEnabled() {
+ assert_refreshUi_switchPreferenceSetEnabled(true /* isPermissionDeclared */);
+ }
+
+ @Test
+ public void refreshUi_isPermissibleFalse_switchPreferenceUnChecked() {
+ assert_refreshUi_switchPreferenceSetChecked(false /* isPermissible */);
+ }
+
+ @Test
+ public void refreshUi_isPermissibleTrue_switchPreferenceChecked() {
+ assert_refreshUi_switchPreferenceSetChecked(true /* isPermissible */);
+ }
+
+ private void assert_refreshUi_switchPreferenceSetEnabled(boolean isPermissionDeclared) {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+ mPackageInfo.applicationInfo = new ApplicationInfo();
+ when(mAppStateBridge.createPermissionState(nullable(String.class), anyInt()))
+ .thenReturn(mPermissionState);
+ mPermissionState.permissionDeclared = isPermissionDeclared;
+
+ mFragment.refreshUi();
+ verify(mSwitchPref).setEnabled(isPermissionDeclared);
+ }
+
+ private void assert_refreshUi_switchPreferenceSetChecked(boolean isPermissible) {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+ mPackageInfo.applicationInfo = new ApplicationInfo();
+ when(mAppStateBridge.createPermissionState(nullable(String.class), anyInt()))
+ .thenReturn(mPermissionState);
+ when(mPermissionState.isPermissible()).thenReturn(isPermissible);
+
+ mFragment.refreshUi();
+ verify(mSwitchPref).setChecked(isPermissible);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivityTest.java
index d3a1fc1..bf1d256 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintSuggestionActivityTest.java
@@ -25,6 +25,7 @@
import android.app.KeyguardManager;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.hardware.biometrics.ComponentInfoInternal;
import android.hardware.biometrics.SensorProperties;
import android.hardware.fingerprint.FingerprintSensorProperties;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
@@ -53,6 +54,7 @@
import org.robolectric.shadows.ShadowKeyguardManager;
import java.util.ArrayList;
+import java.util.List;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {
@@ -70,10 +72,19 @@
Shadows.shadowOf(application.getPackageManager())
.setSystemFeature(PackageManager.FEATURE_FINGERPRINT, true);
+ final List<ComponentInfoInternal> componentInfo = new ArrayList<>();
+ componentInfo.add(new ComponentInfoInternal("faceSensor" /* componentId */,
+ "vendor/model/revision" /* hardwareVersion */, "1.01" /* firmwareVersion */,
+ "00000001" /* serialNumber */, "" /* softwareVersion */));
+ componentInfo.add(new ComponentInfoInternal("matchingAlgorithm" /* componentId */,
+ "" /* hardwareVersion */, "" /* firmwareVersion */, "" /* serialNumber */,
+ "vendor/version/revision" /* softwareVersion */));
+
final FingerprintSensorPropertiesInternal prop = new FingerprintSensorPropertiesInternal(
0 /* sensorId */,
SensorProperties.STRENGTH_STRONG,
5 /* maxEnrollmentsPerUser */,
+ componentInfo,
FingerprintSensorProperties.TYPE_REAR,
true /* resetLockoutRequiresHardwareAuthToken */);
final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java
index 25780f7..f8517ba 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java
@@ -24,8 +24,8 @@
import android.app.KeyguardManager;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.hardware.biometrics.ComponentInfoInternal;
import android.hardware.biometrics.SensorProperties;
-import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorProperties;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.view.View;
@@ -59,6 +59,7 @@
import org.robolectric.shadows.ShadowKeyguardManager;
import java.util.ArrayList;
+import java.util.List;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {
@@ -76,10 +77,19 @@
Shadows.shadowOf(application.getPackageManager())
.setSystemFeature(PackageManager.FEATURE_FINGERPRINT, true);
+ final List<ComponentInfoInternal> componentInfo = new ArrayList<>();
+ componentInfo.add(new ComponentInfoInternal("faceSensor" /* componentId */,
+ "vendor/model/revision" /* hardwareVersion */, "1.01" /* firmwareVersion */,
+ "00000001" /* serialNumber */, "" /* softwareVersion */));
+ componentInfo.add(new ComponentInfoInternal("matchingAlgorithm" /* componentId */,
+ "" /* hardwareVersion */, "" /* firmwareVersion */, "" /* serialNumber */,
+ "vendor/version/revision" /* softwareVersion */));
+
final FingerprintSensorPropertiesInternal prop = new FingerprintSensorPropertiesInternal(
0 /* sensorId */,
SensorProperties.STRENGTH_STRONG,
5 /* maxEnrollmentsPerUser */,
+ componentInfo,
FingerprintSensorProperties.TYPE_REAR,
true /* resetLockoutRequiresHardwareAuthToken */);
final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index c8891e5..8e03d68 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -62,6 +62,9 @@
private static final int BATTERY_LEVEL_RIGHT = 45;
private static final int LOW_BATTERY_LEVEL = 15;
private static final int CASE_LOW_BATTERY_LEVEL = 19;
+ private static final int LOW_BATTERY_LEVEL_THRESHOLD = 15;
+ private static final int BATTERY_LEVEL_5 = 5;
+ private static final int BATTERY_LEVEL_50 = 50;
private static final String ICON_URI = "content://test.provider/icon.png";
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
@@ -202,6 +205,70 @@
}
@Test
+ public void refresh_underLowBatteryThreshold_showAlertIcon() {
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
+ BluetoothDevice.DEVICE_TYPE_WATCH.getBytes());
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_MAIN_BATTERY)).thenReturn(
+ String.valueOf(BATTERY_LEVEL_5).getBytes());
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_MAIN_LOW_BATTERY_THRESHOLD)).thenReturn(
+ String.valueOf(LOW_BATTERY_LEVEL_THRESHOLD).getBytes());
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_MAIN_CHARGING)).thenReturn(
+ String.valueOf(false).getBytes());
+ when(mCachedDevice.isConnected()).thenReturn(true);
+
+ mController.refresh();
+
+ assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle),
+ R.drawable.ic_battery_alert_24dp);
+ }
+
+ @Test
+ public void refresh_underLowBatteryThresholdInCharging_showAlertIcon() {
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
+ BluetoothDevice.DEVICE_TYPE_WATCH.getBytes());
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_MAIN_BATTERY)).thenReturn(
+ String.valueOf(BATTERY_LEVEL_5).getBytes());
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_MAIN_LOW_BATTERY_THRESHOLD)).thenReturn(
+ String.valueOf(LOW_BATTERY_LEVEL_THRESHOLD).getBytes());
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_MAIN_CHARGING)).thenReturn(
+ String.valueOf(true).getBytes());
+ when(mCachedDevice.isConnected()).thenReturn(true);
+
+ mController.refresh();
+
+ assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle), /* resId= */-1);
+ }
+
+ @Test
+ public void refresh_aboveLowBatteryThreshold_noAlertIcon() {
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
+ BluetoothDevice.DEVICE_TYPE_WATCH.getBytes());
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_MAIN_BATTERY)).thenReturn(
+ String.valueOf(BATTERY_LEVEL_50).getBytes());
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_MAIN_LOW_BATTERY_THRESHOLD)).thenReturn(
+ String.valueOf(LOW_BATTERY_LEVEL_THRESHOLD).getBytes());
+ when(mBluetoothDevice.getMetadata(
+ BluetoothDevice.METADATA_MAIN_CHARGING)).thenReturn(
+ String.valueOf(false).getBytes());
+ when(mCachedDevice.isConnected()).thenReturn(true);
+
+ mController.refresh();
+
+ assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle), /* resId= */-1);
+ }
+
+ @Test
public void refresh_withLowBatteryAndUncharged_showAlertIcon() {
when(mBluetoothDevice.getMetadata(
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn(
diff --git a/tests/robotests/src/com/android/settings/development/DefaultUsbConfigurationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DefaultUsbConfigurationPreferenceControllerTest.java
index 15f4eb9..c9b13e27 100644
--- a/tests/robotests/src/com/android/settings/development/DefaultUsbConfigurationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DefaultUsbConfigurationPreferenceControllerTest.java
@@ -91,4 +91,27 @@
verify(mPreference).setDisabledByAdmin(eq(new RestrictedLockUtils.EnforcedAdmin(
TEST_COMPONENT_NAME, null, UserHandle.SYSTEM)));
}
+
+ @Test
+ public void onDeveloperOptionsSwitchEnabled_usbEnabled_shouldNotDisablePreference() {
+ when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
+ UserHandle.myUserId())).thenReturn(true);
+ when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
+
+ mController.onDeveloperOptionsSwitchEnabled();
+
+ verify(mPreference).setDisabledByAdmin(null);
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchEnabled_usbDisabled_shouldDisablePreference() {
+ when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
+ UserHandle.myUserId())).thenReturn(false);
+ when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
+
+ mController.onDeveloperOptionsSwitchEnabled();
+
+ verify(mPreference).setDisabledByAdmin(eq(new RestrictedLockUtils.EnforcedAdmin(
+ TEST_COMPONENT_NAME, null, UserHandle.SYSTEM)));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/development/UsbAudioRoutingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/UsbAudioRoutingPreferenceControllerTest.java
index 1d45c1b..69d2c99 100644
--- a/tests/robotests/src/com/android/settings/development/UsbAudioRoutingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/UsbAudioRoutingPreferenceControllerTest.java
@@ -147,4 +147,27 @@
verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false);
}
+
+ @Test
+ public void onDeveloperOptionsSwitchEnabled_usbEnabled_shouldNotDisablePreference() {
+ when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
+ UserHandle.myUserId())).thenReturn(true);
+ when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
+
+ mController.onDeveloperOptionsSwitchEnabled();
+
+ verify(mPreference).setDisabledByAdmin(null);
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchEnabled_usbDisabled_shouldDisablePreference() {
+ when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
+ UserHandle.myUserId())).thenReturn(false);
+ when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
+
+ mController.onDeveloperOptionsSwitchEnabled();
+
+ verify(mPreference).setDisabledByAdmin(eq(new RestrictedLockUtils.EnforcedAdmin(
+ TEST_COMPONENT_NAME, null, UserHandle.SYSTEM)));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java
deleted file mode 100644
index ed7f16b..0000000
--- a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.deviceinfo;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.Activity;
-import android.content.pm.PackageManager;
-import android.os.storage.VolumeInfo;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-
-import com.android.settings.R;
-
-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.Robolectric;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.shadows.ShadowApplication;
-
-@RunWith(RobolectricTestRunner.class)
-public class PrivateVolumeOptionMenuControllerTest {
-
- @Mock
- private MenuItem mMigrateMenuItem;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Menu mMenu;
- @Mock
- private MenuInflater mMenuInflater;
- @Mock
- private PackageManager mPm;
- @Mock
- private VolumeInfo mVolumeInfo;
- @Mock
- private VolumeInfo mPrimaryInfo;
-
- private PrivateVolumeOptionMenuController mController;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- when(mVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
- when(mVolumeInfo.isMountedWritable()).thenReturn(true);
- when(mPrimaryInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
- when(mMenu.findItem(anyInt())).thenReturn(mMigrateMenuItem);
- when(mMigrateMenuItem.getItemId()).thenReturn(100);
-
- mController = new PrivateVolumeOptionMenuController(
- Robolectric.setupActivity(Activity.class), mPrimaryInfo, mPm);
- }
-
- @Test
- public void testMigrateDataMenuItemIsAdded() {
- mController.onCreateOptionsMenu(mMenu, mMenuInflater);
-
- verify(mMenu).add(Menu.NONE, 100, Menu.NONE, R.string.storage_menu_migrate);
- }
-
- @Test
- public void testMigrateDataIsNotVisibleNormally() {
- when(mPm.getPrimaryStorageCurrentVolume()).thenReturn(mPrimaryInfo);
- when(mPrimaryInfo.isMountedWritable()).thenReturn(true);
-
- mController.onCreateOptionsMenu(mMenu, mMenuInflater);
- mController.onPrepareOptionsMenu(mMenu);
-
- verify(mMigrateMenuItem).setVisible(false);
- }
-
- @Test
- public void testMigrateDataIsVisibleWhenExternalVolumeIsPrimary() {
- when(mPm.getPrimaryStorageCurrentVolume()).thenReturn(mVolumeInfo);
-
- mController.onCreateOptionsMenu(mMenu, mMenuInflater);
- mController.onPrepareOptionsMenu(mMenu);
-
- verify(mMigrateMenuItem).setVisible(true);
- }
-
- @Test
- public void testMigrateDataIsNotVisibleWhenExternalVolumeIsNotMounted() {
- when(mPm.getPrimaryStorageCurrentVolume()).thenReturn(mVolumeInfo);
- when(mVolumeInfo.isMountedWritable()).thenReturn(false);
-
- mController.onCreateOptionsMenu(mMenu, mMenuInflater);
- mController.onPrepareOptionsMenu(mMenu);
-
- verify(mMigrateMenuItem).setVisible(false);
- }
-
- @Test
- public void testMigrateDataGoesToMigrateWizard() {
- when(mPm.getPrimaryStorageCurrentVolume()).thenReturn(mVolumeInfo);
-
- mController.onCreateOptionsMenu(mMenu, mMenuInflater);
- mController.onPrepareOptionsMenu(mMenu);
-
- assertThat(mController.onOptionsItemSelected(mMigrateMenuItem)).isTrue();
- ShadowApplication shadowApplication = ShadowApplication.getInstance();
- assertThat(shadowApplication).isNotNull();
- assertThat(shadowApplication.getNextStartedActivity().getComponent().getClassName())
- .isEqualTo(StorageWizardMigrateConfirm.class.getName());
- }
-}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
index 997c35e..60eab12 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
@@ -181,8 +181,8 @@
mController.copy();
- final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
- CLIPBOARD_SERVICE);
+ final ClipboardManager clipboard = mContext.getSystemService(
+ ClipboardManager.class);
final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
assertThat(data.toString()).isEqualTo(meid);
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/BasePrivacySettingsPreferenceTest.java b/tests/robotests/src/com/android/settings/enterprise/BasePrivacySettingsPreferenceTest.java
new file mode 100644
index 0000000..fdf005d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/enterprise/BasePrivacySettingsPreferenceTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+import com.android.settings.widget.PreferenceCategoryController;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public abstract class BasePrivacySettingsPreferenceTest {
+
+ protected Context mContext;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ }
+
+ protected static void verifyEnterpriseSearchIndexableResources(
+ List<SearchIndexableResource> searchIndexableResources) {
+ assertThat(searchIndexableResources).isNotEmpty();
+ assertThat(searchIndexableResources.size()).isEqualTo(1);
+ assertThat(searchIndexableResources.get(0).xmlResId)
+ .isEqualTo(R.xml.enterprise_privacy_settings);
+ }
+
+ protected static void verifyEnterprisePreferenceControllers(
+ List<AbstractPreferenceController> controllers) {
+ assertThat(controllers).isNotNull();
+ assertThat(controllers.size()).isEqualTo(17);
+ int position = 0;
+ assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ SecurityLogsPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ EnterpriseInstalledPackagesPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ AdminGrantedLocationPermissionsPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ AdminGrantedMicrophonePermissionPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ AdminGrantedCameraPermissionPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ EnterpriseSetDefaultAppsPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ AlwaysOnVpnCurrentUserPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ AlwaysOnVpnManagedProfilePreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(ImePreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ GlobalHttpProxyPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ CaCertsCurrentUserPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ CaCertsManagedProfilePreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ PreferenceCategoryController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ FailedPasswordWipeCurrentUserPreferenceController.class);
+ assertThat(controllers.get(position)).isInstanceOf(
+ FailedPasswordWipeManagedProfilePreferenceController.class);
+ }
+
+ protected static void verifyFinancedSearchIndexableResources(
+ List<SearchIndexableResource> searchIndexableResources) {
+ assertThat(searchIndexableResources).isNotEmpty();
+ assertThat(searchIndexableResources.size()).isEqualTo(1);
+ assertThat(searchIndexableResources.get(0).xmlResId)
+ .isEqualTo(R.xml.financed_privacy_settings);
+ }
+
+ protected static void verifyFinancedPreferenceControllers(
+ List<AbstractPreferenceController> controllers) {
+ assertThat(controllers).isNotNull();
+ assertThat(controllers.size()).isEqualTo(6);
+ int position = 0;
+ assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ SecurityLogsPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ EnterpriseInstalledPackagesPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
+ PreferenceCategoryController.class);
+ assertThat(controllers.get(position)).isInstanceOf(
+ FailedPasswordWipeCurrentUserPreferenceController.class);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
index 6858dd3..8052357 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
@@ -16,10 +16,15 @@
package com.android.settings.enterprise;
+import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_DEFAULT;
+import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
import android.content.Context;
import androidx.preference.Preference;
@@ -42,9 +47,14 @@
private static final String MANAGED_WITH_NAME = "managed by Foo, Inc.";
private static final String MANAGING_ORGANIZATION = "Foo, Inc.";
private static final String KEY_ENTERPRISE_PRIVACY = "enterprise_privacy";
+ private static final String FINANCED_PREFERENCE_TITLE = "Financed device info";
+ private static final ComponentName DEVICE_OWNER_COMPONENT =
+ new ComponentName("com.android.foo", "bar");
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
+ @Mock
+ private DevicePolicyManager mDevicePolicyManager;
private FakeFeatureFactory mFeatureFactory;
private EnterprisePrivacyPreferenceController mController;
@@ -54,6 +64,14 @@
MockitoAnnotations.initMocks(this);
mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new EnterprisePrivacyPreferenceController(mContext);
+
+ when((Object) mContext.getSystemService(DevicePolicyManager.class))
+ .thenReturn(mDevicePolicyManager);
+ when(mDevicePolicyManager.isDeviceManaged()).thenReturn(true);
+ when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser())
+ .thenReturn(DEVICE_OWNER_COMPONENT);
+ when(mDevicePolicyManager.getDeviceOwnerType(DEVICE_OWNER_COMPONENT))
+ .thenReturn(DEVICE_OWNER_TYPE_DEFAULT);
}
@Test
@@ -77,6 +95,25 @@
}
@Test
+ public void testUpdateState_verifyPreferenceTitleIsUpdatedForFinancedDevice() {
+ final Preference preference = new Preference(mContext, null, 0, 0);
+ when(mContext.getResources().getString(
+ R.string.enterprise_privacy_settings_summary_with_name, MANAGING_ORGANIZATION))
+ .thenReturn(MANAGED_WITH_NAME);
+ when(mContext.getString(R.string.financed_privacy_settings))
+ .thenReturn(FINANCED_PREFERENCE_TITLE);
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.getDeviceOwnerOrganizationName())
+ .thenReturn(MANAGING_ORGANIZATION);
+ when(mDevicePolicyManager.getDeviceOwnerType(DEVICE_OWNER_COMPONENT))
+ .thenReturn(DEVICE_OWNER_TYPE_FINANCED);
+
+ mController.updateState(preference);
+
+ assertThat(preference.getTitle()).isEqualTo(FINANCED_PREFERENCE_TITLE);
+ assertThat(preference.getSummary()).isEqualTo(MANAGED_WITH_NAME);
+ }
+
+ @Test
public void testIsAvailable() {
when(mFeatureFactory.enterprisePrivacyFeatureProvider.hasDeviceOwner()).thenReturn(false);
assertThat(mController.isAvailable()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
index 2d4ba62..eb70749 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
@@ -16,47 +16,70 @@
package com.android.settings.enterprise;
+import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_DEFAULT;
+
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-import android.content.Context;
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.provider.SearchIndexableResource;
+
+import androidx.test.core.app.ApplicationProvider;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.widget.PreferenceCategoryController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.drawer.CategoryKey;
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.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
-public class EnterprisePrivacySettingsTest {
+public class EnterprisePrivacySettingsTest extends BasePrivacySettingsPreferenceTest {
+ private static final ComponentName DEVICE_OWNER_COMPONENT =
+ new ComponentName("com.android.foo", "bar");
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
+ @Mock
+ private DevicePolicyManager mDevicePolicyManager;
+ @Mock
+ private PrivacySettingsPreference mPrivacySettingsPreference;
private FakeFeatureFactory mFeatureFactory;
private EnterprisePrivacySettings mSettings;
+ @Override
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mContext = spy(ApplicationProvider.getApplicationContext());
mFeatureFactory = FakeFeatureFactory.setupForTest();
mSettings = new EnterprisePrivacySettings();
+ mSettings.mPrivacySettingsPreference = mPrivacySettingsPreference;
+
+ when(mContext.getSystemService(DevicePolicyManager.class)).thenReturn(mDevicePolicyManager);
+ when(mDevicePolicyManager.isDeviceManaged()).thenReturn(true);
+ when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser())
+ .thenReturn(DEVICE_OWNER_COMPONENT);
+ when(mDevicePolicyManager.getDeviceOwnerType(DEVICE_OWNER_COMPONENT))
+ .thenReturn(DEVICE_OWNER_TYPE_DEFAULT);
}
@Test
public void verifyConstants() {
+ when(mPrivacySettingsPreference.getPreferenceScreenResId())
+ .thenReturn(R.xml.enterprise_privacy_settings);
+
assertThat(mSettings.getMetricsCategory())
.isEqualTo(MetricsEvent.ENTERPRISE_PRIVACY_SETTINGS);
assertThat(mSettings.getLogTag()).isEqualTo("EnterprisePrivacySettings");
@@ -76,6 +99,7 @@
@Test
public void isPageEnabled_noDeviceOwner_shouldReturnFalse() {
+ when(mDevicePolicyManager.isDeviceManaged()).thenReturn(false);
when(mFeatureFactory.enterprisePrivacyFeatureProvider.hasDeviceOwner())
.thenReturn(false);
@@ -85,53 +109,35 @@
@Test
public void getPreferenceControllers() {
- final List<AbstractPreferenceController> controllers =
- mSettings.createPreferenceControllers(RuntimeEnvironment.application);
- verifyPreferenceControllers(controllers);
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ controllers.add(new NetworkLogsPreferenceController(mContext));
+ when(mPrivacySettingsPreference.createPreferenceControllers(anyBoolean()))
+ .thenReturn(controllers);
+
+ final List<AbstractPreferenceController> privacyControllers =
+ mSettings.createPreferenceControllers(mContext);
+
+ assertThat(privacyControllers).isNotNull();
+ assertThat(privacyControllers.size()).isEqualTo(1);
+ assertThat(controllers.get(0)).isInstanceOf(NetworkLogsPreferenceController.class);
}
@Test
- public void getSearchIndexProviderPreferenceControllers() {
+ public void
+ getSearchIndexProviderPreferenceControllers_returnsEnterpriseSearchIndexPreferenceControllers() {
final List<AbstractPreferenceController> controllers =
EnterprisePrivacySettings.SEARCH_INDEX_DATA_PROVIDER
- .getPreferenceControllers(RuntimeEnvironment.application);
- verifyPreferenceControllers(controllers);
+ .getPreferenceControllers(mContext);
+
+ verifyEnterprisePreferenceControllers(controllers);
}
- private void verifyPreferenceControllers(List<AbstractPreferenceController> controllers) {
- assertThat(controllers).isNotNull();
- assertThat(controllers.size()).isEqualTo(17);
- int position = 0;
- assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- SecurityLogsPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- EnterpriseInstalledPackagesPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- AdminGrantedLocationPermissionsPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- AdminGrantedMicrophonePermissionPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- AdminGrantedCameraPermissionPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- EnterpriseSetDefaultAppsPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- AlwaysOnVpnCurrentUserPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- AlwaysOnVpnManagedProfilePreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(ImePreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- GlobalHttpProxyPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- CaCertsCurrentUserPreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- CaCertsManagedProfilePreferenceController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- PreferenceCategoryController.class);
- assertThat(controllers.get(position++)).isInstanceOf(
- FailedPasswordWipeCurrentUserPreferenceController.class);
- assertThat(controllers.get(position)).isInstanceOf(
- FailedPasswordWipeManagedProfilePreferenceController.class);
+ @Test
+ public void getXmlResourcesToIndex_returnsEnterpriseXmlResources() {
+ final List<SearchIndexableResource> searchIndexableResources =
+ EnterprisePrivacySettings.SEARCH_INDEX_DATA_PROVIDER
+ .getXmlResourcesToIndex(mContext, true);
+
+ verifyEnterpriseSearchIndexableResources(searchIndexableResources);
}
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/PrivacySettingsEnterprisePreferenceTest.java b/tests/robotests/src/com/android/settings/enterprise/PrivacySettingsEnterprisePreferenceTest.java
new file mode 100644
index 0000000..68e37fc
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/enterprise/PrivacySettingsEnterprisePreferenceTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.provider.SearchIndexableResource;
+
+import com.android.settings.R;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class PrivacySettingsEnterprisePreferenceTest extends BasePrivacySettingsPreferenceTest {
+
+ private PrivacySettingsEnterprisePreference mPrivacySettingsEnterprisePreference;
+
+ @Override
+ @Before
+ public void setUp() {
+ super.setUp();
+ mPrivacySettingsEnterprisePreference = new PrivacySettingsEnterprisePreference(mContext);
+ }
+
+ @Test
+ public void getPreferenceScreenResId() {
+ assertThat(mPrivacySettingsEnterprisePreference.getPreferenceScreenResId())
+ .isEqualTo(R.xml.enterprise_privacy_settings);
+ }
+
+ @Test
+ public void getXmlResourcesToIndex() {
+ final List<SearchIndexableResource> searchIndexableResources =
+ mPrivacySettingsEnterprisePreference.getXmlResourcesToIndex();
+
+ verifyEnterpriseSearchIndexableResources(searchIndexableResources);
+ }
+
+ @Test
+ public void getPreferenceControllers() {
+ final List<AbstractPreferenceController> controllers =
+ mPrivacySettingsEnterprisePreference.createPreferenceControllers(true);
+
+ verifyEnterprisePreferenceControllers(controllers);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/enterprise/PrivacySettingsFinancedPreferenceTest.java b/tests/robotests/src/com/android/settings/enterprise/PrivacySettingsFinancedPreferenceTest.java
new file mode 100644
index 0000000..fe7b214
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/enterprise/PrivacySettingsFinancedPreferenceTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.enterprise;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.provider.SearchIndexableResource;
+
+import com.android.settings.R;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class PrivacySettingsFinancedPreferenceTest extends BasePrivacySettingsPreferenceTest {
+
+ private PrivacySettingsFinancedPreference mPrivacySettingsFinancedPreference;
+
+ @Override
+ @Before
+ public void setUp() {
+ super.setUp();
+ mPrivacySettingsFinancedPreference = new PrivacySettingsFinancedPreference(mContext);
+ }
+
+ @Test
+ public void getPreferenceScreenResId() {
+ assertThat(mPrivacySettingsFinancedPreference.getPreferenceScreenResId())
+ .isEqualTo(R.xml.financed_privacy_settings);
+ }
+
+ @Test
+ public void getXmlResourcesToIndex() {
+ final List<SearchIndexableResource> searchIndexableResources =
+ mPrivacySettingsFinancedPreference.getXmlResourcesToIndex();
+
+ verifyFinancedSearchIndexableResources(searchIndexableResources);
+ }
+
+ @Test
+ public void getPreferenceControllers() {
+ final List<AbstractPreferenceController> controllers =
+ mPrivacySettingsFinancedPreference.createPreferenceControllers(true);
+
+ verifyFinancedPreferenceControllers(controllers);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
index dd1a0e1..7f76c70 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
@@ -47,7 +47,6 @@
import androidx.preference.Preference;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -113,8 +112,6 @@
@Mock
private BatteryEntry mBatteryEntry;
@Mock
- private BatteryStatsHelper mBatteryStatsHelper;
- @Mock
private PackageManager mPackageManager;
@Mock
private AppOpsManager mAppOpsManager;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
index 4c2d5ed..744db8c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
@@ -48,14 +48,10 @@
import android.os.BatteryStatsManager;
import android.os.BatteryUsageStats;
import android.os.Build;
-import android.os.Bundle;
import android.os.Process;
import android.os.SystemBatteryConsumer;
import android.os.SystemClock;
-import android.os.UserManager;
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
import com.android.settings.fuelgauge.batterytip.AnomalyInfo;
import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
@@ -97,13 +93,7 @@
private static final long TIME_EXPECTED_FOREGROUND = 1500;
private static final long TIME_EXPECTED_BACKGROUND = 6000;
private static final long TIME_EXPECTED_ALL = 7500;
- private static final double BATTERY_SCREEN_USAGE = 300;
- private static final double BATTERY_IDLE_USAGE = 600;
private static final double BATTERY_SYSTEM_USAGE = 600;
- private static final double BATTERY_OVERACCOUNTED_USAGE = 500;
- private static final double BATTERY_UNACCOUNTED_USAGE = 700;
- private static final double BATTERY_WIFI_USAGE = 200;
- private static final double BATTERY_BLUETOOTH_USAGE = 300;
private static final double TOTAL_BATTERY_USAGE = 1000;
private static final int DISCHARGE_AMOUNT = 80;
private static final double PERCENT_SYSTEM_USAGE = 48;
@@ -125,38 +115,14 @@
@Mock
private SystemBatteryConsumer mSystemBatteryConsumer;
@Mock
- private BatterySipper mNormalBatterySipper;
- @Mock
- private BatterySipper mWifiBatterySipper;
- @Mock
- private BatterySipper mBluetoothBatterySipper;
- @Mock
- private BatterySipper mScreenBatterySipper;
- @Mock
- private BatterySipper mOvercountedBatterySipper;
- @Mock
- private BatterySipper mUnaccountedBatterySipper;
- @Mock
- private BatterySipper mSystemBatterySipper;
- @Mock
- private BatterySipper mCellBatterySipper;
- @Mock
- private BatterySipper mIdleBatterySipper;
- @Mock
private BatteryInfo mBatteryInfo;
@Mock
- private Bundle mBundle;
- @Mock
- private UserManager mUserManager;
- @Mock
private PackageManager mPackageManager;
@Mock
private AppOpsManager mAppOpsManager;
@Mock
private ApplicationInfo mApplicationInfo;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private BatteryStatsHelper mBatteryStatsHelper;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private BatteryStatsManager mBatteryStatsManager;
@Mock
private ApplicationInfo mHighApplicationInfo;
@@ -170,7 +136,6 @@
private BatteryUtils mBatteryUtils;
private FakeFeatureFactory mFeatureFactory;
private PowerUsageFeatureProvider mProvider;
- private List<BatterySipper> mUsageList;
private Context mContext;
@Before
@@ -190,8 +155,6 @@
anyLong(), anyInt());
doReturn(TIME_STATE_BACKGROUND).when(mUid).getProcessStateTime(eq(PROCESS_STATE_BACKGROUND),
anyLong(), anyInt());
- when(mBatteryStatsHelper.getStats().computeBatteryRealtime(anyLong(), anyInt())).thenReturn(
- TIME_SINCE_LAST_FULL_CHARGE_US);
when(mPackageManager.getApplicationInfo(eq(HIGH_SDK_PACKAGE), anyInt()))
.thenReturn(mHighApplicationInfo);
@@ -200,32 +163,6 @@
mHighApplicationInfo.targetSdkVersion = Build.VERSION_CODES.O;
mLowApplicationInfo.targetSdkVersion = Build.VERSION_CODES.L;
- mNormalBatterySipper.drainType = BatterySipper.DrainType.APP;
- mNormalBatterySipper.totalPowerMah = TOTAL_BATTERY_USAGE;
- doReturn(UID).when(mNormalBatterySipper).getUid();
-
- mWifiBatterySipper.drainType = BatterySipper.DrainType.WIFI;
- mWifiBatterySipper.totalPowerMah = BATTERY_WIFI_USAGE;
-
- mBluetoothBatterySipper.drainType = BatterySipper.DrainType.BLUETOOTH;
- mBluetoothBatterySipper.totalPowerMah = BATTERY_BLUETOOTH_USAGE;
-
- mScreenBatterySipper.drainType = BatterySipper.DrainType.SCREEN;
- mScreenBatterySipper.totalPowerMah = BATTERY_SCREEN_USAGE;
-
- mSystemBatterySipper.drainType = BatterySipper.DrainType.APP;
- mSystemBatterySipper.totalPowerMah = BATTERY_SYSTEM_USAGE;
- when(mSystemBatterySipper.getUid()).thenReturn(Process.SYSTEM_UID);
-
- mOvercountedBatterySipper.drainType = BatterySipper.DrainType.OVERCOUNTED;
- mOvercountedBatterySipper.totalPowerMah = BATTERY_OVERACCOUNTED_USAGE;
-
- mUnaccountedBatterySipper.drainType = BatterySipper.DrainType.UNACCOUNTED;
- mUnaccountedBatterySipper.totalPowerMah = BATTERY_UNACCOUNTED_USAGE;
-
- mIdleBatterySipper.drainType = BatterySipper.DrainType.IDLE;
- mIdleBatterySipper.totalPowerMah = BATTERY_IDLE_USAGE;
-
mContext = spy(RuntimeEnvironment.application);
doReturn(mPackageManager).when(mContext).getPackageManager();
doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
@@ -237,15 +174,6 @@
.getForegroundServiceTotalTimeUs(any(BatteryStats.Uid.class), anyLong());
mAnomalyInfo = new AnomalyInfo(INFO_WAKELOCK);
- mUsageList = new ArrayList<>();
- mUsageList.add(mNormalBatterySipper);
- mUsageList.add(mScreenBatterySipper);
- mUsageList.add(mCellBatterySipper);
- when(mBatteryStatsHelper.getUsageList()).thenReturn(mUsageList);
- when(mBatteryStatsHelper.getTotalPower())
- .thenReturn(TOTAL_BATTERY_USAGE + BATTERY_SCREEN_USAGE);
- when(mBatteryStatsHelper.getStats().getDischargeAmount(anyInt()))
- .thenReturn(DISCHARGE_AMOUNT);
BatteryDatabaseManager.setUpForTest(mBatteryDatabaseManager);
ShadowThreadUtils.setIsMainThread(true);
}
@@ -349,7 +277,7 @@
@Test
public void testCalculateLastFullChargeTime() {
final long currentTimeMs = System.currentTimeMillis();
- when(mBatteryUsageStats.getStatsStartRealtime()).thenReturn(
+ when(mBatteryUsageStats.getStatsStartTimestamp()).thenReturn(
currentTimeMs - TIME_SINCE_LAST_FULL_CHARGE_MS);
assertThat(mBatteryUtils.calculateLastFullChargeTime(mBatteryUsageStats, currentTimeMs))
@@ -406,15 +334,6 @@
}
@Test
- public void testInitBatteryStatsHelper_init() {
- mBatteryUtils.initBatteryStatsHelper(mBatteryStatsHelper, mBundle, mUserManager);
-
- verify(mBatteryStatsHelper).create(mBundle);
- verify(mBatteryStatsHelper).refreshStats(BatteryStats.STATS_SINCE_CHARGED,
- mUserManager.getUserProfiles());
- }
-
- @Test
public void testIsPreOApp_SdkLowerThanO_ReturnTrue() {
assertThat(mBatteryUtils.isPreOApp(LOW_SDK_PACKAGE)).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoaderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoaderTest.java
index 82448d1..5d7b082 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoaderTest.java
@@ -54,7 +54,6 @@
BatteryTip.TipType.BATTERY_SAVER,
BatteryTip.TipType.HIGH_DEVICE_USAGE,
BatteryTip.TipType.LOW_BATTERY,
- BatteryTip.TipType.SUMMARY,
BatteryTip.TipType.SMART_BATTERY_MANAGER};
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private BatteryUsageStats mBatteryUsageStats;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
index b68a8f5..e919288 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
@@ -20,7 +20,6 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -30,10 +29,6 @@
import android.os.Bundle;
import android.text.format.DateUtils;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import com.android.internal.logging.nano.MetricsProto;
@@ -49,7 +44,6 @@
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.RobolectricTestRunner;
@@ -104,10 +98,24 @@
}
@Test
- public void testDisplayPreference_addSummaryTip() {
+ public void testDisplayPreference_isInvisible() {
mBatteryTipPreferenceController.displayPreference(mPreferenceScreen);
- assertOnlyContainsSummaryTip(mCardPreference);
+ assertThat(mCardPreference.isVisible()).isFalse();
+ }
+
+ @Test
+ public void testUpdateBatteryTips_tipsStateNew_isVisible() {
+ mBatteryTipPreferenceController.updateBatteryTips(mOldBatteryTips);
+
+ assertThat(mCardPreference.isVisible()).isTrue();
+ }
+
+ @Test
+ public void testUpdateBatteryTips_tipsStateInvisible_isInvisible() {
+ mBatteryTipPreferenceController.updateBatteryTips(mNewBatteryTips);
+
+ assertThat(mCardPreference.isVisible()).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/EarlyWarningDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/EarlyWarningDetectorTest.java
index dbee7f1..84411a7 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/EarlyWarningDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/EarlyWarningDetectorTest.java
@@ -86,11 +86,11 @@
}
@Test
- public void testDetect_batterySaverOn_tipHandled() {
+ public void testDetect_batterySaverOn_tipInvisible() {
doReturn(true).when(mPowerManager).isPowerSaveMode();
assertThat(mEarlyWarningDetector.detect().getState())
- .isEqualTo(BatteryTip.StateType.HANDLED);
+ .isEqualTo(BatteryTip.StateType.INVISIBLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java
index 55020e2..245bacc 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java
@@ -91,10 +91,11 @@
}
@Test
- public void testDetect_batterySaverOn_tipHandled() {
+ public void testDetect_batterySaverOn_tipInvisible() {
mShadowPowerManager.setIsPowerSaveMode(true);
- assertThat(mLowBatteryDetector.detect().getState()).isEqualTo(BatteryTip.StateType.HANDLED);
+ assertThat(mLowBatteryDetector.detect().getState())
+ .isEqualTo(BatteryTip.StateType.INVISIBLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/EarlyWarningTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/EarlyWarningTipTest.java
index 85b00c8..aeea10f 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/EarlyWarningTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/EarlyWarningTipTest.java
@@ -74,24 +74,13 @@
}
@Test
- public void testInfo_stateHandled_displayPowerModeHandledInfo() {
- final EarlyWarningTip tip =
- new EarlyWarningTip(BatteryTip.StateType.HANDLED, false /* powerModeOn */);
-
- assertThat(tip.getTitle(mContext)).isEqualTo("Battery Saver is on");
- assertThat(tip.getSummary(mContext)).isEqualTo("Some features may be limited");
- assertThat(tip.getIconId()).isEqualTo(R.drawable.ic_battery_status_maybe_24dp);
- assertThat(tip.getIconTintColorId()).isEqualTo(R.color.battery_maybe_color_light);
- }
-
- @Test
- public void testUpdate_powerModeTurnedOn_typeBecomeHandled() {
+ public void testUpdate_powerModeTurnedOn_typeBecomeInvisible() {
final EarlyWarningTip nextTip =
new EarlyWarningTip(BatteryTip.StateType.INVISIBLE, true /* powerModeOn */);
mEarlyWarningTip.updateState(nextTip);
- assertThat(mEarlyWarningTip.getState()).isEqualTo(BatteryTip.StateType.HANDLED);
+ assertThat(mEarlyWarningTip.getState()).isEqualTo(BatteryTip.StateType.INVISIBLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTipTest.java
index 11dffcd..244faea 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTipTest.java
@@ -65,13 +65,6 @@
}
@Test
- public void getSummary_tipHandled_showSummary() {
- mLowBatteryTip.mState = BatteryTip.StateType.HANDLED;
-
- assertThat(mLowBatteryTip.getSummary(mContext)).isEqualTo("Some features may be limited");
- }
-
- @Test
public void getSummary_tipNew_showSummary() {
mLowBatteryTip.mState = BatteryTip.StateType.NEW;
diff --git a/tests/robotests/src/com/android/settings/gestures/OneHandedEnablePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/OneHandedEnablePreferenceControllerTest.java
index 11128f3..b53629e 100644
--- a/tests/robotests/src/com/android/settings/gestures/OneHandedEnablePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/OneHandedEnablePreferenceControllerTest.java
@@ -51,14 +51,16 @@
public void setChecked_setBoolean_checkIsTrueOrFalse() {
mController.setChecked(false);
assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isFalse();
+ assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isTrue();
mController.setChecked(true);
assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isTrue();
+ assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isFalse();
}
@Test
public void getAvailabilityStatus_setSupportOneHandedModeProperty_shouldAvailable() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE);
@@ -66,7 +68,7 @@
@Test
public void getAvailabilityStatus_unsetSupportOneHandedModeProperty_shouldUnsupported() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
diff --git a/tests/robotests/src/com/android/settings/gestures/OneHandedSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/OneHandedSettingsTest.java
index fcea919..2651708 100644
--- a/tests/robotests/src/com/android/settings/gestures/OneHandedSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/OneHandedSettingsTest.java
@@ -55,7 +55,7 @@
@Test
public void isPageSearchEnabled_setSupportOneHandedModeProperty_shouldReturnTrue() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
final Object obj = ReflectionHelpers.callInstanceMethod(
OneHandedSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
@@ -66,7 +66,7 @@
@Test
public void isPageSearchEnabled_unsetSupportOneHandedModeProperty_shouldReturnFalse() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
final Object obj = ReflectionHelpers.callInstanceMethod(
OneHandedSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceControllerTest.java
index a1c0c8f..9f76800 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceControllerTest.java
@@ -16,10 +16,7 @@
package com.android.settings.gestures;
-import static android.provider.Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED;
-
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
import static com.google.common.truth.Truth.assertThat;
@@ -28,6 +25,7 @@
import android.provider.Settings;
import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -57,44 +55,33 @@
public void setChecked_toggledOn_enablesSwipeBottomToNotification() {
mController.setChecked(true);
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 1)).isEqualTo(1);
+ assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isTrue();
+ assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isFalse();
}
@Test
public void setChecked_toggledOff_disablesSwipeBottomToNotification() {
mController.setChecked(false);
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 1)).isEqualTo(0);
+ assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isFalse();
}
@Test
- public void getAvailabilityStatus_oneHandedUnsupported_returnsAvailable() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
+ public void getAvailabilityStatus_oneHandedUnsupported_returnsUnsupport() {
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_oneHandedSupported_returnsAvailable() {
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
- public void getAvailabilityStatus_oneHandedDisabled_returnsAvailable() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ONE_HANDED_MODE_ENABLED, 0);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_oneHandedEnabled_returnsDisabled() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ONE_HANDED_MODE_ENABLED, 1);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
- }
-
- @Test
public void getSummary_gestureEnabled_returnsOnSummary() {
mController.setChecked(true);
@@ -109,4 +96,13 @@
assertThat(mController.getSummary()).isEqualTo(
mContext.getText(R.string.gesture_setting_off));
}
+
+ @Test
+ public void isChecked_getDefaultConfig_returnFalse() {
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
+ Settings.Secure.resetToDefaults(mContext.getContentResolver(),
+ Settings.Secure.ONE_HANDED_MODE_ENABLED);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationSettingsTest.java
index ad8104c..3a65b26 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationSettingsTest.java
@@ -21,7 +21,6 @@
import android.content.Context;
import android.os.SystemProperties;
import android.provider.SearchIndexableResource;
-import android.provider.Settings;
import com.android.settings.R;
@@ -64,22 +63,21 @@
}
@Test
- public void isPageSearchEnabled_oneHandedUnsupported_shouldReturnTrue() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
+ public void isPageSearchEnabled_oneHandedUnsupported_shouldReturnFalse() {
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
final Object obj = ReflectionHelpers.callInstanceMethod(
SwipeBottomToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
ReflectionHelpers.ClassParameter.from(Context.class, mContext));
final boolean isEnabled = (Boolean) obj;
- assertThat(isEnabled).isTrue();
+ assertThat(isEnabled).isFalse();
}
@Test
public void isPageSearchEnabled_oneHandedDisabled_shouldReturnTrue() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ONE_HANDED_MODE_ENABLED, 0);
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
+ OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, false);
final Object obj = ReflectionHelpers.callInstanceMethod(
SwipeBottomToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
@@ -91,9 +89,8 @@
@Test
public void isPageSearchEnabled_oneHandedEnabled_shouldReturnFalse() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ONE_HANDED_MODE_ENABLED, 1);
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
+ OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, true);
final Object obj = ReflectionHelpers.callInstanceMethod(
SwipeBottomToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
diff --git a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java
index 173f625..c7a2650 100644
--- a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java
@@ -25,16 +25,20 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.ActivityManager;
import android.os.Build;
-import android.util.FeatureFlagUtils;
+import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
+import androidx.fragment.app.Fragment;
+
import com.android.settings.R;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.core.HideNonSystemOverlayMixin;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
import com.android.settings.homepage.contextualcards.slices.BatteryFixSliceTest;
+import com.android.settings.testutils.shadow.ShadowUserManager;
import org.junit.Before;
import org.junit.Test;
@@ -46,15 +50,20 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowActivityManager;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowUserManager.class,
+ SettingsHomepageActivityTest.ShadowSuggestionFeatureProviderImpl.class})
public class SettingsHomepageActivityTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FeatureFlagUtils.setEnabled(RuntimeEnvironment.application, FeatureFlags.SILKY_HOME, false);
}
@Test
@@ -67,6 +76,77 @@
}
@Test
+ public void launch_configDisabled_shouldHideAvatar() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+
+ final View avatarView = activity.findViewById(R.id.account_avatar);
+ assertThat(avatarView.getVisibility()).isNotEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void launch_configEnabled_shouldShowAvatar() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+
+ final View avatarView = activity.findViewById(R.id.account_avatar);
+ assertThat(avatarView.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void launch_LowRamDevice_shouldHideAvatar() {
+ final ShadowActivityManager activityManager = Shadow.extract(
+ RuntimeEnvironment.application.getSystemService(ActivityManager.class));
+ activityManager.setIsLowRamDevice(true);
+
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+
+ final View avatarView = activity.findViewById(R.id.account_avatar);
+ assertThat(avatarView.getVisibility()).isNotEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void showHomepageWithSuggestion_showSuggestion() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+ final View viewRoot = activity.findViewById(R.id.settings_homepage_container);
+ final View suggestionTile = activity.findViewById(R.id.suggestion_content);
+
+ activity.showHomepageWithSuggestion(true);
+
+ assertThat(viewRoot.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(suggestionTile.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void showHomepageWithSuggestion_hideSuggestion() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+ final View viewRoot = activity.findViewById(R.id.settings_homepage_container);
+ final View suggestionTile = activity.findViewById(R.id.suggestion_content);
+
+ activity.showHomepageWithSuggestion(false);
+
+ assertThat(viewRoot.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(suggestionTile.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void showHomepageWithSuggestion_callTwice_shouldKeepPreviousVisibility() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+ final View suggestionTile = activity.findViewById(R.id.suggestion_content);
+
+ activity.showHomepageWithSuggestion(false);
+ activity.showHomepageWithSuggestion(true);
+
+ assertThat(suggestionTile.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
@Config(shadows = {
BatteryFixSliceTest.ShadowBatteryTipLoader.class
})
@@ -114,4 +194,13 @@
assertThat(paramCaptor.getValue().privateFlags
& SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS).isEqualTo(0);
}
+
+ @Implements(SuggestionFeatureProviderImpl.class)
+ public static class ShadowSuggestionFeatureProviderImpl {
+
+ @Implementation
+ public Class<? extends Fragment> getContextualSuggestionFragment() {
+ return Fragment.class;
+ }
+ }
}
diff --git a/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
index d3a3129..53dd959 100644
--- a/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
@@ -57,7 +57,7 @@
mContext = spy(ApplicationProvider.getApplicationContext());
mSwitchPreference = spy(SwitchPreference.class);
- when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
+ when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
mController = new BluetoothTetherPreferenceController(mContext, "BLUETOOTH");
mController.setTetherEnabler(mTetherEnabler);
diff --git a/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java
index 8a81908..de642f6 100644
--- a/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java
@@ -62,9 +62,9 @@
public void setUp() {
mContext = spy(ApplicationProvider.getApplicationContext());
mPreference = spy(SwitchPreference.class);
- when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
+ when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[]{ETHERNET_REGEX});
- when(mContext.getSystemService(Context.ETHERNET_SERVICE)).thenReturn(mEthernetManager);
+ when(mContext.getSystemService(EthernetManager.class)).thenReturn(mEthernetManager);
mController = new EthernetTetherPreferenceController(mContext, "ethernet");
mController.setTetherEnabler(mTetherEnabler);
ReflectionHelpers.setField(mController, "mEthernetRegex", ETHERNET_REGEX);
diff --git a/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java b/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java
index 8996c1d..293b649 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java
@@ -45,14 +45,14 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+ when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
mRestrictionChecker = spy(new NetworkResetRestrictionChecker(mContext));
}
@Test
public void testHasRestriction_notAdmin_shouldReturnTrue() {
final Context context = mock(Context.class);
- when(context.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+ when(context.getSystemService(UserManager.class)).thenReturn(mUserManager);
when(mUserManager.isAdminUser()).thenReturn(false);
assertThat(mRestrictionChecker.hasRestriction()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
index 390a674..fce9517 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
@@ -125,7 +125,7 @@
mContext = spy(RuntimeEnvironment.application);
mContentResolver = mContext.getContentResolver();
mShadowContentResolver = Shadow.extract(mContentResolver);
- when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
+ when(mContext.getSystemService(ConnectivityManager.class))
.thenReturn(mConnectivityManager);
doNothing().when(mConnectivityManager).registerDefaultNetworkCallback(
mCallbackCaptor.capture(), nullable(Handler.class));
diff --git a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
index bb4b0c4..cd93865 100644
--- a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
@@ -95,10 +95,10 @@
AtomicReference<BluetoothPan> panReference = spy(AtomicReference.class);
mSwitchBar = spy(new SwitchBar(context));
mSwitchWidgetController = spy(new SwitchBarController(mSwitchBar));
- when(context.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
- when(context.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
+ when(context.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
+ when(context.getSystemService(ConnectivityManager.class)).thenReturn(
mConnectivityManager);
- when(context.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
+ when(context.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(context.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(
mNetworkPolicyManager);
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
@@ -311,4 +311,4 @@
assertThat(TetherEnabler.isTethering(TETHERING_ETHERNET_ON, TETHERING_ETHERNET)).isTrue();
assertThat(TetherEnabler.isTethering(~TETHERING_ETHERNET_ON, TETHERING_ETHERNET)).isFalse();
}
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
index e02da90..0639ef3 100644
--- a/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
@@ -55,7 +55,7 @@
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
- when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
+ when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
mController = new UsbTetherPreferenceController(mContext, "USB");
mController.setTetherEnabler(mTetherEnabler);
diff --git a/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
index a82a71f..22ed55c 100644
--- a/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
@@ -100,7 +100,7 @@
mContext = spy(ApplicationProvider.getApplicationContext());
mPreference = spy(SwitchPreference.class);
- when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
+ when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
mController = new WifiTetherDisablePreferenceController(mContext, WIFI_TETHER_DISABLE_KEY);
mController.setTetherEnabler(mTetherEnabler);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
index ba37c30..acc6b1a 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
@@ -74,7 +74,7 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
+ doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
diff --git a/tests/robotests/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java b/tests/robotests/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java
index 6bee38f..0d86408 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java
@@ -77,7 +77,7 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
+ when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java
index 634b9a8..6b92e57 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java
@@ -65,7 +65,6 @@
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -233,7 +232,6 @@
}
@Test
- @Ignore
public void updatePreferencesOrFinish_callingAppIsAdmin_deviceNotProvisioned_footerInvisible() {
Global.putInt(application.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
initActivity(new Intent().putExtra(EXTRA_KEY_IS_CALLING_APP_ADMIN, true));
diff --git a/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java b/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java
index 79d4b6b..af44d39 100644
--- a/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java
@@ -50,7 +50,6 @@
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -105,18 +104,17 @@
}
@Test
- @Ignore
public void testSetupChooseLockGeneric() {
Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, 0);
+ Intent intent = new Intent(ACTION_SET_NEW_PASSWORD);
+ intent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
SetNewPasswordActivity activity =
- Robolectric.buildActivity(SetNewPasswordActivity.class).get();
- activity.launchChooseLock(new Bundle());
+ Robolectric.buildActivity(SetNewPasswordActivity.class, intent).create().get();
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
- Intent intent = getLaunchChooseLockIntent(shadowActivity);
- intent.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true);
- assertThat(intent.getComponent())
+ Intent nextIntent = shadowActivity.getNextStartedActivityForResult().intent;
+ assertThat(nextIntent.getComponent())
.isEqualTo(new ComponentName(activity, SetupChooseLockGeneric.class));
}
diff --git a/tests/robotests/src/com/android/settings/privacy/ShowClipAccessNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/ShowClipAccessNotificationPreferenceControllerTest.java
new file mode 100644
index 0000000..c707cd6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/privacy/ShowClipAccessNotificationPreferenceControllerTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.privacy;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+import android.provider.Settings.SettingNotFoundException;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class ShowClipAccessNotificationPreferenceControllerTest {
+
+ @Mock
+ private PreferenceScreen mScreen;
+
+ private Context mContext;
+ private ShowClipAccessNotificationPreferenceController mController;
+ private Preference mPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new ShowClipAccessNotificationPreferenceController(mContext);
+ mPreference = new Preference(mContext);
+ mPreference.setKey(mController.getPreferenceKey());
+ }
+
+ @Test
+ public void isChecked_settingIsOff_shouldReturnFalse() throws Exception {
+ setProperty(0);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isChecked_settingIsOn_shouldReturnTrue() throws Exception {
+ setProperty(1);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void onPreferenceChange_turnOn_shouldChangeSettingTo1() throws Exception {
+ setProperty(0);
+
+ mController.onPreferenceChange(mPreference, true);
+
+ assertThat(mController.isChecked()).isTrue();
+ assertProperty(1);
+ }
+
+ @Test
+ public void onPreferenceChange_turnOff_shouldChangeSettingTo0() throws Exception {
+ setProperty(1);
+
+ mController.onPreferenceChange(mPreference, false);
+
+ assertThat(mController.isChecked()).isFalse();
+ assertProperty(0);
+ }
+
+ private void setProperty(int newValue) {
+ final ContentResolver contentResolver = mContext.getContentResolver();
+ Settings.Secure.putInt(
+ contentResolver, Settings.Secure.CLIPBOARD_SHOW_ACCESS_NOTIFICATIONS, newValue);
+ }
+
+ private void assertProperty(int expectedValue) throws SettingNotFoundException {
+ final ContentResolver contentResolver = mContext.getContentResolver();
+ assertThat(Settings.Secure.getInt(
+ contentResolver, Settings.Secure.CLIPBOARD_SHOW_ACCESS_NOTIFICATIONS))
+ .isEqualTo(expectedValue);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
index a48b3eb..7bd7813 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -30,6 +30,7 @@
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
@@ -58,6 +59,7 @@
public final SupportFeatureProvider supportFeatureProvider;
public final MetricsFeatureProvider metricsFeatureProvider;
public final BatteryStatusFeatureProvider batteryStatusFeatureProvider;
+ public final BatterySettingsFeatureProvider batterySettingsFeatureProvider;
public final PowerUsageFeatureProvider powerUsageFeatureProvider;
public final DashboardFeatureProvider dashboardFeatureProvider;
public final DockUpdaterFeatureProvider dockUpdaterFeatureProvider;
@@ -106,6 +108,7 @@
supportFeatureProvider = mock(SupportFeatureProvider.class);
metricsFeatureProvider = mock(MetricsFeatureProvider.class);
batteryStatusFeatureProvider = mock(BatteryStatusFeatureProvider.class);
+ batterySettingsFeatureProvider = mock(BatterySettingsFeatureProvider.class);
powerUsageFeatureProvider = mock(PowerUsageFeatureProvider.class);
dashboardFeatureProvider = mock(DashboardFeatureProvider.class);
dockUpdaterFeatureProvider = mock(DockUpdaterFeatureProvider.class);
@@ -150,6 +153,11 @@
}
@Override
+ public BatterySettingsFeatureProvider getBatterySettingsFeatureProvider(Context context) {
+ return batterySettingsFeatureProvider;
+ }
+
+ @Override
public PowerUsageFeatureProvider getPowerUsageFeatureProvider(Context context) {
return powerUsageFeatureProvider;
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
index 094e282..be3267e 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
@@ -78,7 +78,7 @@
mActivity = spy(activity);
mWifiManager = mock(WifiManager.class);
- when(mActivity.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
+ when(mActivity.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java
index 65cc811..2475d80 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java
@@ -53,7 +53,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
+ when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
mEnabler = new WifiEnabler(mContext, mock(SwitchWidgetController.class),
mock(MetricsFeatureProvider.class), mConnectivityManager);
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java
index b94df29..4100d05 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java
@@ -78,7 +78,7 @@
when(mContext.getSystemService(NetworkScoreManager.class)).thenReturn(mNetworkScoreManager);
mController = new WifiPrimarySwitchPreferenceController(mContext, mMetricsFeatureProvider);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
- when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
+ when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
when(mWifiManager.getWifiState()).thenReturn(WifiManager.WIFI_STATE_DISABLED);
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
index 7eba586..428a360 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
@@ -209,7 +209,7 @@
final Resources.Theme theme = mContext.getTheme();
when(activity.getTheme()).thenReturn(theme);
UserManager userManager = mock(UserManager.class);
- when(activity.getSystemService(Context.USER_SERVICE))
+ when(activity.getSystemService(UserManager.class))
.thenReturn(userManager);
when(mWifiSettings.findPreference(WifiSettings.PREF_KEY_DATA_USAGE))
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/DisclaimerItemListAdapterTest.java b/tests/robotests/src/com/android/settings/wifi/calling/DisclaimerItemListAdapterTest.java
index 8478a54..3e15348 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/DisclaimerItemListAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/DisclaimerItemListAdapterTest.java
@@ -77,7 +77,7 @@
when(mLayoutInflater.inflate(anyInt(), anyObject(), anyBoolean())).thenReturn(mView);
when(mViewGroup.getContext()).thenReturn(mContext);
- when(mViewGroup.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).thenReturn(
+ when(mViewGroup.getContext().getSystemService(LayoutInflater.class)).thenReturn(
mLayoutInflater);
when(mView.findViewById(ID_DISCLAIMER_ITEM_TITLE)).thenReturn(mTestView);
when(mView.findViewById(ID_DISCLAIMER_ITEM_DESCRIPTION)).thenReturn(mDescView);
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/EmergencyCallLimitationDisclaimerTest.java b/tests/robotests/src/com/android/settings/wifi/calling/EmergencyCallLimitationDisclaimerTest.java
index 985edda..c15e850 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/EmergencyCallLimitationDisclaimerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/EmergencyCallLimitationDisclaimerTest.java
@@ -54,7 +54,7 @@
mContext = spy(RuntimeEnvironment.application);
doReturn(mCarrierConfigManager).when(mContext).getSystemService(
- Context.CARRIER_CONFIG_SERVICE);
+ CarrierConfigManager.class);
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/LocationPolicyDisclaimerTest.java b/tests/robotests/src/com/android/settings/wifi/calling/LocationPolicyDisclaimerTest.java
index 3fe9678..108acf8 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/LocationPolicyDisclaimerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/LocationPolicyDisclaimerTest.java
@@ -54,7 +54,7 @@
mContext = spy(RuntimeEnvironment.application);
doReturn(mCarrierConfigManager).when(mContext).getSystemService(
- Context.CARRIER_CONFIG_SERVICE);
+ CarrierConfigManager.class);
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());
}
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2Test.java
index e0fb578..66b5bcb 100644
--- a/tests/robotests/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2Test.java
@@ -24,9 +24,9 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import android.app.settings.SettingsEnums;
import android.view.Menu;
@@ -36,12 +36,17 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
+import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.wifitrackerlib.NetworkDetailsTracker;
+import com.android.wifitrackerlib.WifiEntry;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@@ -52,11 +57,22 @@
final String TEST_PREFERENCE_KEY = "TEST_PREFERENCE_KEY";
+ @Mock
+ WifiEntry mWifiEntry;
+ @Mock
+ NetworkDetailsTracker mNetworkDetailsTracker;
+ @Mock
+ Menu mMenu;
private WifiNetworkDetailsFragment2 mFragment;
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ doReturn(mWifiEntry).when(mNetworkDetailsTracker).getWifiEntry();
+ doReturn(true).when(mWifiEntry).isSaved();
+
mFragment = new WifiNetworkDetailsFragment2();
+ mFragment.mNetworkDetailsTracker = mNetworkDetailsTracker;
}
@Test
@@ -77,16 +93,24 @@
@Test
public void onCreateOptionsMenu_shouldSetCorrectIcon() {
- final Menu menu = mock(Menu.class);
final MenuItem menuItem = mock(MenuItem.class);
- doReturn(menuItem).when(menu).add(anyInt(), eq(Menu.FIRST), anyInt(), anyInt());
+ doReturn(menuItem).when(mMenu).add(anyInt(), eq(Menu.FIRST), anyInt(), anyInt());
- mFragment.onCreateOptionsMenu(menu, mock(MenuInflater.class));
+ mFragment.onCreateOptionsMenu(mMenu, mock(MenuInflater.class));
verify(menuItem).setIcon(com.android.internal.R.drawable.ic_mode_edit);
}
@Test
+ public void onCreateOptionsMenu_isNotSavedNetwork_shouldNotAddEditMenu() {
+ doReturn(false).when(mWifiEntry).isSaved();
+
+ mFragment.onCreateOptionsMenu(mMenu, mock(MenuInflater.class));
+
+ verify(mMenu, never()).add(anyInt(), anyInt(), anyInt(), eq(R.string.wifi_modify));
+ }
+
+ @Test
public void refreshPreferences_controllerShouldUpdateStateAndDisplayPreference() {
final FakeFragment fragment = spy(new FakeFragment());
final PreferenceScreen screen = mock(PreferenceScreen.class);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
index d777a59..252d876 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
@@ -73,8 +73,8 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mPreference = new ListPreference(RuntimeEnvironment.application);
- when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
- when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
+ when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
+ when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
index 2ecc7d2..9a34323 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
@@ -80,10 +80,10 @@
MockitoAnnotations.initMocks(this);
doReturn(mConnectivityManager)
- .when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
- doReturn(mTetheringManager).when(mContext).getSystemService(Context.TETHERING_SERVICE);
+ .when(mContext).getSystemService(ConnectivityManager.class);
+ doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
doReturn(WIFI_REGEXS).when(mTetheringManager).getTetherableWifiRegexs();
- doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
+ doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
mWifiTetherSettings = new WifiTetherSettings();
}
@@ -133,7 +133,7 @@
when(settings.getContext()).thenReturn(mContext);
final Resources.Theme theme = mContext.getTheme();
when(activity.getTheme()).thenReturn(theme);
- when(activity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+ when(activity.getSystemService(UserManager.class)).thenReturn(mUserManager);
doNothing().when(settings)
.onCreatePreferences(any(Bundle.class), nullable(String.class));
final FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
diff --git a/tests/uitests/AndroidManifest.xml b/tests/uitests/AndroidManifest.xml
index dc6fc15..1072754 100644
--- a/tests/uitests/AndroidManifest.xml
+++ b/tests/uitests/AndroidManifest.xml
@@ -26,6 +26,8 @@
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES"/>
diff --git a/tests/unit/Android.bp b/tests/unit/Android.bp
index b55a788..408f2d3 100644
--- a/tests/unit/Android.bp
+++ b/tests/unit/Android.bp
@@ -32,6 +32,9 @@
"platform-test-annotations",
"truth-prebuilt",
"ub-uiautomator",
+ "SettingsLibSettingsSpinner",
+ "SettingsLibUsageProgressBarPreference",
+ "SettingsLibTwoTargetPreference",
],
// Include all test java files.
diff --git a/tests/unit/AndroidManifest.xml b/tests/unit/AndroidManifest.xml
index 616e6a9..7ef7ae1 100644
--- a/tests/unit/AndroidManifest.xml
+++ b/tests/unit/AndroidManifest.xml
@@ -19,6 +19,8 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
diff --git a/tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsIntensityPreferenceControllerTest.java b/tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsIntensityPreferenceControllerTest.java
index 8dac893..22d0b29 100644
--- a/tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsIntensityPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsIntensityPreferenceControllerTest.java
@@ -24,7 +24,6 @@
import android.content.Context;
import android.content.res.Resources;
-import android.hardware.display.ColorDisplayManager;
import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
@@ -83,8 +82,8 @@
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 1);
mPreferenceController.onPreferenceChange(/* preference= */ null, 20);
assertThat(
- mContext.getSystemService(
- ColorDisplayManager.class).getReduceBrightColorsStrength())
+ Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.REDUCE_BRIGHT_COLORS_LEVEL, 0))
.isEqualTo(20);
}
diff --git a/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java
index cf4c53e..a34e634 100644
--- a/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java
@@ -23,9 +23,18 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import android.apphibernation.AppHibernationManager;
import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.provider.DeviceConfig;
import androidx.test.core.app.ApplicationProvider;
@@ -34,23 +43,40 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
-/**
- * TODO(b/181172051): test getNumberHibernated() when the API implemented
- */
+import java.util.Arrays;
+
@RunWith(AndroidJUnit4.class)
public class HibernatedAppsPreferenceControllerTest {
+ public static final String HIBERNATED_PACKAGE_NAME = "hibernated_package";
+ public static final String AUTO_REVOKED_PACKAGE_NAME = "auto_revoked_package";
+ public static final String PERMISSION = "permission";
+ @Mock
+ PackageManager mPackageManager;
+ @Mock
+ AppHibernationManager mAppHibernationManager;
private static final String KEY = "key";
private Context mContext;
private HibernatedAppsPreferenceController mController;
+ private PackageInfo mHibernatedPackage;
+ private PackageInfo mAutoRevokedPackage;
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
DeviceConfig.setProperty(NAMESPACE_APP_HIBERNATION, PROPERTY_APP_HIBERNATION_ENABLED,
"true", false);
mContext = spy(ApplicationProvider.getApplicationContext());
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mContext.getSystemService(AppHibernationManager.class))
+ .thenReturn(mAppHibernationManager);
mController = new HibernatedAppsPreferenceController(mContext, KEY);
+ mHibernatedPackage =
+ getHibernatedPackage(mAppHibernationManager, mPackageManager, mContext);
+ mAutoRevokedPackage = getAutoRevokedPackage(mPackageManager, mContext);
}
@Test
@@ -60,4 +86,38 @@
assertThat((mController).getAvailabilityStatus()).isNotEqualTo(AVAILABLE);
}
+
+ @Test
+ public void getSummary_shouldReturnCorrectly() {
+ when(mPackageManager.getInstalledPackages(anyInt())).thenReturn(
+ Arrays.asList(mHibernatedPackage, mAutoRevokedPackage, new PackageInfo()));
+ when(mContext.getResources()).thenReturn(mock(Resources.class));
+ final int totalHibernated = 2;
+
+ mController.getSummary();
+ verify(mContext.getResources()).getQuantityString(
+ anyInt(), eq(totalHibernated), eq(totalHibernated));
+ }
+
+ private static PackageInfo getHibernatedPackage(
+ AppHibernationManager apm, PackageManager pm, Context context) {
+ final PackageInfo pi = new PackageInfo();
+ pi.packageName = HIBERNATED_PACKAGE_NAME;
+ pi.requestedPermissions = new String[] {PERMISSION};
+ when(apm.getHibernatingPackagesForUser()).thenReturn(Arrays.asList(pi.packageName));
+ when(pm.getPermissionFlags(
+ pi.requestedPermissions[0], pi.packageName, context.getUser()))
+ .thenReturn(PackageManager.FLAG_PERMISSION_AUTO_REVOKED);
+ return pi;
+ }
+
+ private static PackageInfo getAutoRevokedPackage(PackageManager pm, Context context) {
+ final PackageInfo pi = new PackageInfo();
+ pi.packageName = AUTO_REVOKED_PACKAGE_NAME;
+ pi.requestedPermissions = new String[] {PERMISSION};
+ when(pm.getPermissionFlags(
+ pi.requestedPermissions[0], pi.packageName, context.getUser()))
+ .thenReturn(PackageManager.FLAG_PERMISSION_AUTO_REVOKED);
+ return pi;
+ }
}
diff --git a/tests/unit/src/com/android/settings/applications/appinfo/HibernationSwitchPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/appinfo/HibernationSwitchPreferenceControllerTest.java
index e27942a..65ffe4b 100644
--- a/tests/unit/src/com/android/settings/applications/appinfo/HibernationSwitchPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/appinfo/HibernationSwitchPreferenceControllerTest.java
@@ -70,9 +70,9 @@
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(Context.APP_OPS_SERVICE)).thenReturn(mAppOpsManager);
- when(mPackageManager.getPackageUidAsUser(eq(VALID_PACKAGE_NAME), anyInt()))
+ when(mPackageManager.getPackageUid(eq(VALID_PACKAGE_NAME), anyInt()))
.thenReturn(PACKAGE_UID);
- when(mPackageManager.getPackageUidAsUser(eq(INVALID_PACKAGE_NAME), anyInt()))
+ when(mPackageManager.getPackageUid(eq(INVALID_PACKAGE_NAME), anyInt()))
.thenThrow(new PackageManager.NameNotFoundException());
when(mPackageManager.getTargetSdkVersion(eq(EXEMPTED_PACKAGE_NAME)))
.thenReturn(android.os.Build.VERSION_CODES.Q);
diff --git a/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java
index 216658f..25d9893 100644
--- a/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java
@@ -21,21 +21,26 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+
import android.content.ComponentName;
import android.content.Context;
import android.os.Looper;
import android.service.autofill.AutofillServiceInfo;
+import androidx.lifecycle.Lifecycle;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
+import androidx.test.annotation.UiThreadTest;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.collect.Lists;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -100,11 +105,15 @@
assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(0);
}
+ @Ignore("TODO: Fix the test to handle the service binding.")
@Test
+ @UiThreadTest
public void displayPreference_withPasswords_addsPreference() {
AutofillServiceInfo service = createServiceWithPasswords();
PasswordsPreferenceController controller =
createControllerWithServices(Lists.newArrayList(service));
+ controller.onCreate(() -> mock(Lifecycle.class));
+
controller.displayPreference(mScreen);
assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
diff --git a/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java b/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
index 9c50d61..f186238 100644
--- a/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
+++ b/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
@@ -19,6 +19,7 @@
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_ALARMS_AND_REMINDERS;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_ALL;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_INSTALL_SOURCES;
+import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_MEDIA_MANAGEMENT;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_POWER_ALLOWLIST;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_RECENT;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_USAGE_ACCESS;
@@ -29,6 +30,7 @@
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_HIGH_POWER;
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MAIN;
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MANAGE_SOURCES;
+import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MEDIA_MANAGEMENT_APPS;
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MOVIES;
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION;
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_OVERLAY;
@@ -64,6 +66,9 @@
assertThat(registry.getDefaultFilterType(LIST_TYPE_ALARMS_AND_REMINDERS))
.isEqualTo(FILTER_ALARMS_AND_REMINDERS);
+ assertThat(registry.getDefaultFilterType(LIST_TYPE_MEDIA_MANAGEMENT_APPS))
+ .isEqualTo(FILTER_APPS_MEDIA_MANAGEMENT);
+
assertThat(registry.getDefaultFilterType(LIST_TYPE_MAIN)).isEqualTo(FILTER_APPS_ALL);
assertThat(registry.getDefaultFilterType(LIST_TYPE_NOTIFICATION))
.isEqualTo(FILTER_APPS_RECENT);
diff --git a/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java
new file mode 100644
index 0000000..314f8c2
--- /dev/null
+++ b/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo;
+
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.storage.DiskInfo;
+import android.os.storage.StorageManager;
+import android.os.storage.VolumeInfo;
+import android.os.storage.VolumeRecord;
+import android.view.Menu;
+
+import androidx.fragment.app.Fragment;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settings.deviceinfo.storage.StorageEntry;
+
+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;
+
+@RunWith(AndroidJUnit4.class)
+public class VolumeOptionMenuControllerTest {
+
+ private static final String INTERNAL_VOLUME_ID = "1";
+ private static final String EXTERNAL_VOLUME_ID = "2";
+ private static final String DISK_ID = "3";
+ private static final String VOLUME_RECORD_FSUUID = "volume_record_fsuuid";
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Menu mMenu;
+ @Mock private PackageManager mPackageManager;
+ @Mock private StorageManager mStorageManager;
+ @Mock private VolumeInfo mExternalVolumeInfo;
+ @Mock private VolumeInfo mInternalVolumeInfo;
+
+ private Context mContext;
+ private VolumeOptionMenuController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mContext.getSystemService(StorageManager.class)).thenReturn(mStorageManager);
+
+ when(mInternalVolumeInfo.getId()).thenReturn(INTERNAL_VOLUME_ID);
+ when(mInternalVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
+ when(mInternalVolumeInfo.getState()).thenReturn(VolumeInfo.STATE_MOUNTED);
+ when(mInternalVolumeInfo.isMountedWritable()).thenReturn(true);
+ when(mExternalVolumeInfo.getId()).thenReturn(EXTERNAL_VOLUME_ID);
+
+ final StorageEntry selectedStorageEntry = new StorageEntry(mContext, mInternalVolumeInfo);
+ mController = new VolumeOptionMenuController(mContext, mock(Fragment.class),
+ selectedStorageEntry);
+ }
+
+ @Test
+ public void onPrepareOptionsMenu_unSupportedDiskInfo_formatIsVisible() {
+ final StorageEntry unsupportedStorageEntry =
+ new StorageEntry(new DiskInfo(DISK_ID, 0 /* flags */));
+ mController.setSelectedStorageEntry(unsupportedStorageEntry);
+
+ mController.onPrepareOptionsMenu(mMenu);
+
+ verify(mController.mFormat, atLeastOnce()).setVisible(true);
+ verify(mController.mRename, never()).setVisible(true);
+ verify(mController.mMount, never()).setVisible(true);
+ verify(mController.mUnmount, never()).setVisible(true);
+ verify(mController.mFormatAsPortable, never()).setVisible(true);
+ verify(mController.mFormatAsInternal, never()).setVisible(true);
+ verify(mController.mMigrate, never()).setVisible(true);
+ verify(mController.mFree, never()).setVisible(true);
+ verify(mController.mForget, never()).setVisible(true);
+ }
+
+ @Test
+ public void onPrepareOptionsMenu_missingVolumeRecord_forgetIsVisible() {
+ final StorageEntry missingStorageEntry =
+ new StorageEntry(new VolumeRecord(0 /* type */, VOLUME_RECORD_FSUUID));
+ mController.setSelectedStorageEntry(missingStorageEntry);
+
+ mController.onPrepareOptionsMenu(mMenu);
+
+ verify(mController.mForget, atLeastOnce()).setVisible(true);
+ verify(mController.mRename, never()).setVisible(true);
+ verify(mController.mMount, never()).setVisible(true);
+ verify(mController.mUnmount, never()).setVisible(true);
+ verify(mController.mFormat, never()).setVisible(true);
+ verify(mController.mFormatAsPortable, never()).setVisible(true);
+ verify(mController.mFormatAsInternal, never()).setVisible(true);
+ verify(mController.mMigrate, never()).setVisible(true);
+ verify(mController.mFree, never()).setVisible(true);
+ }
+
+ @Test
+ public void onPrepareOptionsMenu_unmountedStorage_mountIsVisible() {
+ when(mInternalVolumeInfo.getState()).thenReturn(VolumeInfo.STATE_UNMOUNTED);
+ mController.setSelectedStorageEntry(new StorageEntry(mContext, mInternalVolumeInfo));
+
+ mController.onPrepareOptionsMenu(mMenu);
+
+ verify(mController.mMount, atLeastOnce()).setVisible(true);
+ verify(mController.mRename, never()).setVisible(true);
+ verify(mController.mUnmount, never()).setVisible(true);
+ verify(mController.mFormat, never()).setVisible(true);
+ verify(mController.mFormatAsPortable, never()).setVisible(true);
+ verify(mController.mFormatAsInternal, never()).setVisible(true);
+ verify(mController.mMigrate, never()).setVisible(true);
+ verify(mController.mFree, never()).setVisible(true);
+ verify(mController.mForget, never()).setVisible(true);
+ }
+
+ @Test
+ public void onPrepareOptionsMenu_privateNotDefaultInternal_someMenusAreVisible() {
+ mController.onPrepareOptionsMenu(mMenu);
+
+ verify(mController.mRename, atLeastOnce()).setVisible(true);
+ verify(mController.mUnmount, atLeastOnce()).setVisible(true);
+ verify(mController.mFormatAsPortable, atLeastOnce()).setVisible(true);
+ verify(mController.mMount, never()).setVisible(true);
+ verify(mController.mFormat, never()).setVisible(true);
+ verify(mController.mFormatAsInternal, never()).setVisible(true);
+ verify(mController.mFree, never()).setVisible(true);
+ verify(mController.mForget, never()).setVisible(true);
+ }
+
+ @Test
+ public void onPrepareOptionsMenu_privateDefaultInternal_mostMenusAreNotVisible() {
+ when(mInternalVolumeInfo.getId()).thenReturn(VolumeInfo.ID_PRIVATE_INTERNAL);
+ when(mPackageManager.getPrimaryStorageCurrentVolume()).thenReturn(mInternalVolumeInfo);
+
+ mController.onPrepareOptionsMenu(mMenu);
+
+ verify(mController.mRename, never()).setVisible(true);
+ verify(mController.mUnmount, never()).setVisible(true);
+ verify(mController.mFormatAsPortable, never()).setVisible(true);
+ verify(mController.mMount, never()).setVisible(true);
+ verify(mController.mFormat, never()).setVisible(true);
+ verify(mController.mFormatAsInternal, never()).setVisible(true);
+ verify(mController.mFree, never()).setVisible(true);
+ verify(mController.mForget, never()).setVisible(true);
+ }
+
+ @Test
+ public void onPrepareOptionsMenu_publicStorage_someMenusArcVisible() {
+ when(mExternalVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PUBLIC);
+ when(mExternalVolumeInfo.getState()).thenReturn(VolumeInfo.STATE_MOUNTED);
+ when(mExternalVolumeInfo.getDiskId()).thenReturn(DISK_ID);
+ final DiskInfo externalDiskInfo = mock(DiskInfo.class);
+ when(mStorageManager.findDiskById(DISK_ID)).thenReturn(externalDiskInfo);
+ mController.setSelectedStorageEntry(new StorageEntry(mContext, mExternalVolumeInfo));
+
+ mController.onPrepareOptionsMenu(mMenu);
+
+ verify(mController.mRename, atLeastOnce()).setVisible(true);
+ verify(mController.mUnmount, atLeastOnce()).setVisible(true);
+ verify(mController.mFormat, atLeastOnce()).setVisible(true);
+ verify(mController.mMount, never()).setVisible(true);
+ verify(mController.mFormatAsPortable, never()).setVisible(true);
+ verify(mController.mFormatAsInternal, never()).setVisible(true);
+ verify(mController.mFree, never()).setVisible(true);
+ verify(mController.mForget, never()).setVisible(true);
+ }
+
+ @Test
+ public void onPrepareOptionsMenu_noExternalStorage_migrateNotVisible() {
+ when(mPackageManager.getPrimaryStorageCurrentVolume()).thenReturn(mInternalVolumeInfo);
+
+ mController.onPrepareOptionsMenu(mMenu);
+
+ verify(mController.mMigrate, atLeastOnce()).setVisible(false);
+ verify(mController.mMigrate, never()).setVisible(true);
+ }
+
+ @Test
+ public void onPrepareOptionsMenu_externalPrimaryStorageAvailable_migrateIsVisible() {
+ when(mExternalVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
+ when(mExternalVolumeInfo.isMountedWritable()).thenReturn(true);
+ when(mPackageManager.getPrimaryStorageCurrentVolume()).thenReturn(mExternalVolumeInfo);
+
+ mController.onPrepareOptionsMenu(mMenu);
+
+ verify(mController.mMigrate, atLeastOnce()).setVisible(true);
+ }
+
+ @Test
+ public void onPrepareOptionsMenu_externalUnmounted_migrateIsVisible() {
+ when(mExternalVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
+ when(mExternalVolumeInfo.isMountedWritable()).thenReturn(false);
+ when(mPackageManager.getPrimaryStorageCurrentVolume()).thenReturn(mExternalVolumeInfo);
+
+ mController.onPrepareOptionsMenu(mMenu);
+
+ verify(mController.mMigrate, atLeastOnce()).setVisible(false);
+ verify(mController.mMigrate, never()).setVisible(true);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageEntryTest.java b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageEntryTest.java
new file mode 100644
index 0000000..cf1b6b2
--- /dev/null
+++ b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageEntryTest.java
@@ -0,0 +1,301 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.storage;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.storage.DiskInfo;
+import android.os.storage.StorageManager;
+import android.os.storage.VolumeInfo;
+import android.os.storage.VolumeRecord;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.io.File;
+import java.util.Objects;
+
+@RunWith(AndroidJUnit4.class)
+public class StorageEntryTest {
+
+ private static final String VOLUME_INFO_ID = "volume_info_id";
+ private static final String DISK_INFO_ID = "disk_info_id";
+ private static final String VOLUME_RECORD_UUID = "volume_record_id";
+
+ @Mock
+ private VolumeInfo mVolumeInfo;
+ @Mock
+ private DiskInfo mDiskInfo;
+ @Mock
+ private VolumeRecord mVolumeRecord;
+
+ private Context mContext;
+ @Mock
+ private StorageManager mStorageManager;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ when(mContext.getSystemService(StorageManager.class)).thenReturn(mStorageManager);
+ }
+
+ @Test
+ public void equals_volumesOfSameId_shouldBeTheSame() {
+ final StorageEntry volumeStorage1 = new StorageEntry(mContext,
+ new VolumeInfo(VOLUME_INFO_ID, 0 /* type */, null /* disk */, null /* partGuid */));
+ final StorageEntry volumeStorage2 = new StorageEntry(mContext,
+ new VolumeInfo(VOLUME_INFO_ID, 0 /* type */, null /* disk */, null /* partGuid */));
+ final StorageEntry diskStorage1 =
+ new StorageEntry(new DiskInfo(DISK_INFO_ID, 0 /* flags */));
+ final StorageEntry diskStorage2 =
+ new StorageEntry(new DiskInfo(DISK_INFO_ID, 0 /* flags */));
+ final StorageEntry volumeRecordStorage1 = new StorageEntry(new VolumeRecord(0 /* flags */,
+ VOLUME_RECORD_UUID));
+ final StorageEntry volumeRecordStorage2 = new StorageEntry(new VolumeRecord(0 /* flags */,
+ VOLUME_RECORD_UUID));
+
+ assertThat(Objects.equals(volumeStorage1, volumeStorage2)).isTrue();
+ assertThat(Objects.equals(diskStorage1, diskStorage2)).isTrue();
+ assertThat(Objects.equals(volumeRecordStorage1, volumeRecordStorage2)).isTrue();
+ }
+
+ @Test
+ public void equals_volumesOfDifferentId_shouldBeDifferent() {
+ final StorageEntry volumeStorage1 = new StorageEntry(mContext,
+ new VolumeInfo(VOLUME_INFO_ID, 0 /* type */, null /* disk */, null /* partGuid */));
+ final StorageEntry volumeStorage2 = new StorageEntry(mContext,
+ new VolumeInfo("id2", 0 /* type */, null /* disk */, null /* partGuid */));
+ final StorageEntry diskStorage1 =
+ new StorageEntry(new DiskInfo(DISK_INFO_ID, 0 /* flags */));
+ final StorageEntry diskStorage2 =
+ new StorageEntry(new DiskInfo("id2", 0 /* flags */));
+ final StorageEntry volumeRecordStorage1 = new StorageEntry(new VolumeRecord(0 /* flags */,
+ VOLUME_RECORD_UUID));
+ final StorageEntry volumeRecordStorage2 = new StorageEntry(new VolumeRecord(0 /* flags */,
+ "id2"));
+
+ assertThat(Objects.equals(volumeStorage1, volumeStorage2)).isFalse();
+ assertThat(Objects.equals(diskStorage1, diskStorage2)).isFalse();
+ assertThat(Objects.equals(volumeRecordStorage1, volumeRecordStorage2)).isFalse();
+ }
+
+ @Test
+ public void compareTo_defaultInternalStorage_shouldBeAtTopMost() {
+ final StorageEntry storage1 = mock(StorageEntry.class);
+ when(storage1.isDefaultInternalStorage()).thenReturn(true);
+ final StorageEntry storage2 = mock(StorageEntry.class);
+ when(storage2.isDefaultInternalStorage()).thenReturn(false);
+
+ assertThat(storage1.compareTo(storage2) > 0).isTrue();
+ }
+
+ @Test
+ public void getDefaultInternalStorageEntry_shouldReturnVolumeInfoStorageOfIdPrivateInternal() {
+ final VolumeInfo volumeInfo = mock(VolumeInfo.class);
+ when(mStorageManager.findVolumeById(VolumeInfo.ID_PRIVATE_INTERNAL)).thenReturn(volumeInfo);
+
+ assertThat(StorageEntry.getDefaultInternalStorageEntry(mContext))
+ .isEqualTo(new StorageEntry(mContext, volumeInfo));
+ }
+
+ @Test
+ public void isVolumeInfo_shouldReturnTrueForVolumeInfo() {
+ final VolumeInfo volumeInfo = mock(VolumeInfo.class);
+ final StorageEntry storage = new StorageEntry(mContext, volumeInfo);
+
+ assertThat(storage.isVolumeInfo()).isTrue();
+ assertThat(storage.isDiskInfoUnsupported()).isFalse();
+ assertThat(storage.isVolumeRecordMissed()).isFalse();
+ }
+
+ @Test
+ public void isDiskInfoUnsupported_shouldReturnTrueForDiskInfo() {
+ final DiskInfo diskInfo = mock(DiskInfo.class);
+ final StorageEntry storage = new StorageEntry(diskInfo);
+
+ assertThat(storage.isVolumeInfo()).isFalse();
+ assertThat(storage.isDiskInfoUnsupported()).isTrue();
+ assertThat(storage.isVolumeRecordMissed()).isFalse();
+ }
+
+ @Test
+ public void isVolumeRecordMissed_shouldReturnTrueForVolumeRecord() {
+ final VolumeRecord volumeRecord = mock(VolumeRecord.class);
+ final StorageEntry storage = new StorageEntry(volumeRecord);
+
+ assertThat(storage.isVolumeInfo()).isFalse();
+ assertThat(storage.isDiskInfoUnsupported()).isFalse();
+ assertThat(storage.isVolumeRecordMissed()).isTrue();
+ }
+
+ @Test
+ public void isMounted_mountedOrMountedReadOnly_shouldReturnTrue() {
+ final VolumeInfo mountedVolumeInfo1 = mock(VolumeInfo.class);
+ final StorageEntry mountedStorage1 = new StorageEntry(mContext, mountedVolumeInfo1);
+ when(mountedVolumeInfo1.getState()).thenReturn(VolumeInfo.STATE_MOUNTED);
+ final VolumeInfo mountedVolumeInfo2 = mock(VolumeInfo.class);
+ when(mountedVolumeInfo2.getState()).thenReturn(VolumeInfo.STATE_MOUNTED_READ_ONLY);
+ final StorageEntry mountedStorage2 = new StorageEntry(mContext, mountedVolumeInfo2);
+
+ assertThat(mountedStorage1.isMounted()).isTrue();
+ assertThat(mountedStorage2.isMounted()).isTrue();
+ }
+
+ @Test
+ public void isMounted_nonVolumeInfo_shouldReturnFalse() {
+ final DiskInfo diskInfo = mock(DiskInfo.class);
+ final StorageEntry diskStorage = new StorageEntry(diskInfo);
+ final VolumeRecord volumeRecord = mock(VolumeRecord.class);
+ final StorageEntry recordStorage2 = new StorageEntry(volumeRecord);
+
+ assertThat(diskStorage.isMounted()).isFalse();
+ assertThat(recordStorage2.isMounted()).isFalse();
+ }
+
+ @Test
+ public void isUnmountable_unmountableVolume_shouldReturnTrue() {
+ final VolumeInfo unmountableVolumeInfo = mock(VolumeInfo.class);
+ final StorageEntry mountedStorage = new StorageEntry(mContext, unmountableVolumeInfo);
+ when(unmountableVolumeInfo.getState()).thenReturn(VolumeInfo.STATE_UNMOUNTABLE);
+
+ assertThat(mountedStorage.isUnmountable()).isTrue();
+ }
+
+ @Test
+ public void isUnmountable_nonVolumeInfo_shouldReturnFalse() {
+ final DiskInfo diskInfo = mock(DiskInfo.class);
+ final StorageEntry diskStorage = new StorageEntry(diskInfo);
+ final VolumeRecord volumeRecord = mock(VolumeRecord.class);
+ final StorageEntry recordStorage2 = new StorageEntry(volumeRecord);
+
+ assertThat(diskStorage.isUnmountable()).isFalse();
+ assertThat(recordStorage2.isUnmountable()).isFalse();
+ }
+
+ @Test
+ public void isPrivate_privateVolume_shouldReturnTrue() {
+ final VolumeInfo privateVolumeInfo = mock(VolumeInfo.class);
+ final StorageEntry privateStorage = new StorageEntry(mContext, privateVolumeInfo);
+ when(privateVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
+
+ assertThat(privateStorage.isPrivate()).isTrue();
+ }
+
+ @Test
+ public void isPrivate_nonVolumeInfo_shouldReturnFalse() {
+ final DiskInfo diskInfo = mock(DiskInfo.class);
+ final StorageEntry diskStorage = new StorageEntry(diskInfo);
+ final VolumeRecord volumeRecord = mock(VolumeRecord.class);
+ final StorageEntry recordStorage2 = new StorageEntry(volumeRecord);
+
+ assertThat(diskStorage.isPrivate()).isFalse();
+ assertThat(recordStorage2.isPrivate()).isFalse();
+ }
+
+ @Test
+ public void getDescription_shouldReturnDescription() {
+ final String description = "description";
+ final VolumeInfo volumeInfo = mock(VolumeInfo.class);
+ when(mStorageManager.getBestVolumeDescription(volumeInfo)).thenReturn(description);
+ final StorageEntry volumeStorage = new StorageEntry(mContext, volumeInfo);
+ final DiskInfo diskInfo = mock(DiskInfo.class);
+ final StorageEntry diskStorage = new StorageEntry(diskInfo);
+ when(diskInfo.getDescription()).thenReturn(description);
+ final VolumeRecord volumeRecord = mock(VolumeRecord.class);
+ final StorageEntry recordStorage = new StorageEntry(volumeRecord);
+ when(volumeRecord.getNickname()).thenReturn(description);
+
+ assertThat(volumeStorage.getDescription()).isEqualTo(description);
+ assertThat(diskStorage.getDescription()).isEqualTo(description);
+ assertThat(recordStorage.getDescription()).isEqualTo(description);
+ }
+
+ @Test
+ public void getDiskId_shouldReturnDiskId() {
+ final VolumeInfo volumeInfo = mock(VolumeInfo.class);
+ final StorageEntry volumeStorage = new StorageEntry(mContext, volumeInfo);
+ when(volumeInfo.getDiskId()).thenReturn(VOLUME_INFO_ID);
+ final DiskInfo diskInfo = mock(DiskInfo.class);
+ final StorageEntry diskStorage = new StorageEntry(diskInfo);
+ when(diskInfo.getId()).thenReturn(DISK_INFO_ID);
+ final VolumeRecord volumeRecord = mock(VolumeRecord.class);
+ final StorageEntry recordStorage = new StorageEntry(volumeRecord);
+
+ assertThat(volumeStorage.getDiskId()).isEqualTo(VOLUME_INFO_ID);
+ assertThat(diskStorage.getDiskId()).isEqualTo(DISK_INFO_ID);
+ assertThat(recordStorage.getDiskId()).isEqualTo(null);
+ }
+
+ @Test
+ public void getFsUuid_shouldReturnFsUuid() {
+ final VolumeInfo volumeInfo = mock(VolumeInfo.class);
+ final StorageEntry volumeStorage = new StorageEntry(mContext, volumeInfo);
+ when(volumeInfo.getFsUuid()).thenReturn(VOLUME_INFO_ID);
+ final DiskInfo diskInfo = mock(DiskInfo.class);
+ final StorageEntry diskStorage = new StorageEntry(diskInfo);
+ final VolumeRecord volumeRecord = mock(VolumeRecord.class);
+ final StorageEntry recordStorage = new StorageEntry(volumeRecord);
+ when(volumeRecord.getFsUuid()).thenReturn(VOLUME_RECORD_UUID);
+
+ assertThat(volumeStorage.getFsUuid()).isEqualTo(VOLUME_INFO_ID);
+ assertThat(diskStorage.getFsUuid()).isEqualTo(null);
+ assertThat(recordStorage.getFsUuid()).isEqualTo(VOLUME_RECORD_UUID);
+ }
+
+ @Test
+ public void getPath_shouldReturnPath() {
+ final File file = new File("fakePath");
+ final VolumeInfo volumeInfo = mock(VolumeInfo.class);
+ final StorageEntry volumeStorage = new StorageEntry(mContext, volumeInfo);
+ when(volumeInfo.getPath()).thenReturn(file);
+ final DiskInfo diskInfo = mock(DiskInfo.class);
+ final StorageEntry diskStorage = new StorageEntry(diskInfo);
+ final VolumeRecord volumeRecord = mock(VolumeRecord.class);
+ final StorageEntry recordStorage = new StorageEntry(volumeRecord);
+
+ assertThat(volumeStorage.getPath()).isEqualTo(file);
+ assertThat(diskStorage.getPath()).isEqualTo(null);
+ assertThat(recordStorage.getPath()).isEqualTo(null);
+ }
+
+ @Test
+ public void getVolumeInfo_shouldVolumeInfo() {
+ final VolumeInfo volumeInfo = mock(VolumeInfo.class);
+ final StorageEntry volumeStorage = new StorageEntry(mContext, volumeInfo);
+ final DiskInfo diskInfo = mock(DiskInfo.class);
+ final StorageEntry diskStorage = new StorageEntry(diskInfo);
+ final VolumeRecord volumeRecord = mock(VolumeRecord.class);
+ final StorageEntry recordStorage = new StorageEntry(volumeRecord);
+
+ assertThat(volumeStorage.getVolumeInfo()).isEqualTo(volumeInfo);
+ assertThat(diskStorage.getVolumeInfo()).isEqualTo(null);
+ assertThat(recordStorage.getVolumeInfo()).isEqualTo(null);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceControllerTest.java
new file mode 100644
index 0000000..86351cb
--- /dev/null
+++ b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceControllerTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.storage;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.os.Looper;
+import android.os.storage.StorageManager;
+
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settingslib.widget.SettingsSpinnerPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@RunWith(AndroidJUnit4.class)
+public class StorageSelectionPreferenceControllerTest {
+
+ private static final String PREFERENCE_KEY = "preference_key";
+
+ private Context mContext;
+ private StorageManager mStorageManager;
+ private StorageSelectionPreferenceController mController;
+
+ @Before
+ public void setUp() throws Exception {
+ mContext = ApplicationProvider.getApplicationContext();
+ mStorageManager = mContext.getSystemService(StorageManager.class);
+ mController = new StorageSelectionPreferenceController(mContext, PREFERENCE_KEY);
+ }
+
+ @Test
+ public void setStorageEntries_fromStorageManager_correctAdapterItems() {
+ final List<StorageEntry> storageEntries = mStorageManager.getVolumes().stream()
+ .map(volumeInfo -> new StorageEntry(mContext, volumeInfo))
+ .collect(Collectors.toList());
+
+ mController.setStorageEntries(storageEntries);
+
+ final int adapterItemCount = mController.mStorageAdapter.getCount();
+ assertThat(adapterItemCount).isEqualTo(storageEntries.size());
+ for (int i = 0; i < adapterItemCount; i++) {
+ assertThat(storageEntries.get(i).getDescription())
+ .isEqualTo(mController.mStorageAdapter.getItem(i).getDescription());
+ }
+ }
+
+ @Test
+ public void setSelectedStorageEntry_primaryStorage_correctSelectedAdapterItem() {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ final PreferenceScreen preferenceScreen =
+ preferenceManager.createPreferenceScreen(mContext);
+ final SettingsSpinnerPreference spinnerPreference = new SettingsSpinnerPreference(mContext);
+ spinnerPreference.setKey(PREFERENCE_KEY);
+ preferenceScreen.addPreference(spinnerPreference);
+ mController.displayPreference(preferenceScreen);
+ final StorageEntry primaryStorageEntry =
+ StorageEntry.getDefaultInternalStorageEntry(mContext);
+ mController.setStorageEntries(mStorageManager.getVolumes().stream()
+ .map(volumeInfo -> new StorageEntry(mContext, volumeInfo))
+ .collect(Collectors.toList()));
+
+ mController.setSelectedStorageEntry(primaryStorageEntry);
+
+ assertThat((StorageEntry) mController.mSpinnerPreference.getSelectedItem())
+ .isEqualTo(primaryStorageEntry);
+ }
+}
+
diff --git a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceControllerTest.java
new file mode 100644
index 0000000..6d9155a
--- /dev/null
+++ b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceControllerTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.deviceinfo.storage;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.app.usage.StorageStatsManager;
+import android.content.Context;
+import android.os.Looper;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settingslib.widget.UsageProgressBarPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.io.IOException;
+
+@RunWith(AndroidJUnit4.class)
+public class StorageUsageProgressBarPreferenceControllerTest {
+
+ private static final String FAKE_UUID = "95D9-B3A4";
+ private static final long WAIT_TIMEOUT = 10_000L;
+ private static final long FREE_BYTES = 123L;
+ private static final long TOTAL_BYTES = 456L;
+ private static final long USAGE_BYTES = TOTAL_BYTES - FREE_BYTES;
+
+ private Context mContext;
+ private FakeStorageUsageProgressBarPreferenceController mController;
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private StorageStatsManager mStorageStatsManager;
+
+ @Before
+ public void setUp() throws Exception {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ when(mContext.getSystemService(StorageStatsManager.class)).thenReturn(mStorageStatsManager);
+ mController = new FakeStorageUsageProgressBarPreferenceController(mContext, "key");
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ mPreferenceScreen = preferenceManager.createPreferenceScreen(mContext);
+ final UsageProgressBarPreference usageProgressBarPreference =
+ new UsageProgressBarPreference(mContext);
+ usageProgressBarPreference.setKey(mController.getPreferenceKey());
+ mPreferenceScreen.addPreference(usageProgressBarPreference);
+ }
+
+ @Test
+ public void setSelectedStorageEntry_primaryStorage_getPrimaryStorageBytes() throws IOException {
+ final StorageEntry defaultInternalStorageEntry =
+ StorageEntry.getDefaultInternalStorageEntry(mContext);
+ when(mStorageStatsManager.getTotalBytes(defaultInternalStorageEntry.getFsUuid()))
+ .thenReturn(TOTAL_BYTES);
+ when(mStorageStatsManager.getFreeBytes(defaultInternalStorageEntry.getFsUuid()))
+ .thenReturn(FREE_BYTES);
+ mController.displayPreference(mPreferenceScreen);
+
+ synchronized (mController.mLock) {
+ mController.setSelectedStorageEntry(defaultInternalStorageEntry);
+ mController.waitUpdateState(WAIT_TIMEOUT);
+ }
+
+ assertThat(mController.mUsedBytes).isEqualTo(USAGE_BYTES);
+ assertThat(mController.mTotalBytes).isEqualTo(TOTAL_BYTES);
+ }
+
+ private class FakeStorageUsageProgressBarPreferenceController
+ extends StorageUsageProgressBarPreferenceController {
+ private final Object mLock = new Object();
+
+ FakeStorageUsageProgressBarPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ try {
+ mLock.notifyAll();
+ } catch (IllegalMonitorStateException e) {
+ // Catch it for displayPreference to prevent exception by object not locked by
+ // thread before notify. Do nothing.
+ }
+ }
+
+ public void waitUpdateState(long timeout) {
+ try {
+ mLock.wait(timeout);
+ } catch (InterruptedException e) {
+ // Do nothing.
+ }
+ }
+ }
+}
+
diff --git a/tests/unit/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicyTest.java b/tests/unit/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicyTest.java
index 4be2ae6..9b42951 100644
--- a/tests/unit/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicyTest.java
+++ b/tests/unit/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicyTest.java
@@ -94,7 +94,7 @@
final BatteryTipPolicy batteryTipPolicy = new BatteryTipPolicy(mContext);
assertThat(batteryTipPolicy.batteryTipEnabled).isTrue();
- assertThat(batteryTipPolicy.summaryEnabled).isTrue();
+ assertThat(batteryTipPolicy.summaryEnabled).isFalse();
assertThat(batteryTipPolicy.batterySaverTipEnabled).isTrue();
assertThat(batteryTipPolicy.highUsageEnabled).isTrue();
assertThat(batteryTipPolicy.highUsageAppCount).isEqualTo(3);
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java
index ac2e24d..9c5c88b 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java
@@ -33,6 +33,7 @@
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.Uri;
+import android.net.wifi.WifiManager;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
@@ -90,6 +91,8 @@
private SubscriptionInfo mDefaultDataSubscriptionInfo;
@Mock
private Drawable mDrawableWithSignalStrength;
+ @Mock
+ private WifiManager mWifiManager;
@Before
public void setUp() {
@@ -102,13 +105,23 @@
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(
mCarrierConfigManager);
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
+ mBundle.putBoolean(CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL, false);
when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
when(mConnectivityManager.getActiveNetwork()).thenReturn(mNetwork);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
+ when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
+ when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
TestCustomSliceable testCustomSliceable = new TestCustomSliceable();
mProviderModelSliceHelper = new MockProviderModelSliceHelper(mContext, testCustomSliceable);
+
+ final int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
+ when(mDefaultDataSubscriptionInfo.getSubscriptionId()).thenReturn(defaultDataSubId);
+ when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
+ mDefaultDataSubscriptionInfo);
+ when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
+ Arrays.asList(mDefaultDataSubscriptionInfo));
}
@Test
@@ -155,20 +168,9 @@
String expectDisplayName = "Name1";
CharSequence expectedSubtitle = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY);
String networkType = "5G";
-
- final int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mDefaultDataSubscriptionInfo.getSubscriptionId()).thenReturn(defaultDataSubId);
- when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
- when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
- Arrays.asList(mDefaultDataSubscriptionInfo));
-
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
- mBundle.putBoolean(CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL, false);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
+ mTelephonyManager.DATA_CONNECTED, true);
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
-
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
networkType);
@@ -178,7 +180,7 @@
}
@Test
- public void createCarrierRow_hasDdsAndActiveNetworkIsCellular_verifyTitleAndSummary() {
+ public void createCarrierRow_wifiOnhasDdsAndActiveNetworkIsCellular_verifyTitleAndSummary() {
String expectDisplayName = "Name1";
String networkType = "5G";
String connectedText = ResourcesUtils.getResourcesString(mContext,
@@ -186,16 +188,27 @@
CharSequence expectedSubtitle = Html.fromHtml(ResourcesUtils.getResourcesString(mContext,
"preference_summary_default_combination", connectedText, networkType),
Html.FROM_HTML_MODE_LEGACY);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
+ mTelephonyManager.DATA_CONNECTED, true);
+ addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
- final int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mDefaultDataSubscriptionInfo.getSubscriptionId()).thenReturn(defaultDataSubId);
- when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
- when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
- Arrays.asList(mDefaultDataSubscriptionInfo));
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
- mBundle.putBoolean(CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL, false);
+ ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
+ networkType);
+
+ assertThat(testRowBuild.getTitle()).isEqualTo(expectDisplayName);
+ assertThat(testRowBuild.getSubtitle()).isEqualTo(expectedSubtitle);
+ }
+
+ @Test
+ public void createCarrierRow_noNetworkAvailable_verifyTitleAndSummary() {
+ String expectDisplayName = "Name1";
+ CharSequence expectedSubtitle = Html.fromHtml(
+ ResourcesUtils.getResourcesString(mContext, "mobile_data_no_connection"),
+ Html.FROM_HTML_MODE_LEGACY);
+ String networkType = "";
+
+ mockConnections(true, ServiceState.STATE_OUT_OF_SERVICE, expectDisplayName,
+ mTelephonyManager.DATA_DISCONNECTED, false);
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
@@ -207,53 +220,40 @@
@Test
public void isNoCarrierData_mobileDataOnAndNoData_returnTrue() {
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_DISCONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, "",
+ mTelephonyManager.DATA_DISCONNECTED, true);
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isTrue();
}
@Test
public void isNoCarrierData_mobileDataOffAndOutOfService_returnTrue() {
- when(mTelephonyManager.isDataEnabled()).thenReturn(false);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_DISCONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
+ mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
+ mTelephonyManager.DATA_DISCONNECTED, true);
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isTrue();
}
@Test
public void isNoCarrierData_mobileDataOnAndDataConnected_returnFalse() {
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_CONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
+ true);
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isFalse();
}
@Test
public void isNoCarrierData_mobileDataOffAndVoiceIsInService_returnFalse() {
- when(mTelephonyManager.isDataEnabled()).thenReturn(false);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_DISCONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ mockConnections(false, ServiceState.STATE_IN_SERVICE, "",
+ mTelephonyManager.DATA_DISCONNECTED, true);
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isFalse();
}
@Test
public void getMobileDrawable_noCarrierData_getMobileDrawable() throws Throwable {
- when(mTelephonyManager.isDataEnabled()).thenReturn(false);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_DISCONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
- int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
+ mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
+ mTelephonyManager.DATA_DISCONNECTED, true);
when(mConnectivityManager.getActiveNetwork()).thenReturn(null);
Drawable expectDrawable = mock(Drawable.class);
@@ -264,15 +264,10 @@
@Test
public void getMobileDrawable_hasCarrierDataAndDataIsOnCellular_getMobileDrawable()
throws Throwable {
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_CONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
- Drawable drawable = mock(Drawable.class);
- int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
+ true);
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
+ Drawable drawable = mock(Drawable.class);
assertThat(mProviderModelSliceHelper.getMobileDrawable(drawable)).isEqualTo(
mDrawableWithSignalStrength);
@@ -283,14 +278,9 @@
@Test
public void getMobileDrawable_hasCarrierDataAndDataIsOnWifi_getMobileDrawable()
throws Throwable {
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
- when(mTelephonyManager.getDataState()).thenReturn(mTelephonyManager.DATA_CONNECTED);
- when(mTelephonyManager.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
+ mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
+ true);
Drawable drawable = mock(Drawable.class);
- int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
- when(mSubscriptionManager.getActiveSubscriptionInfo(defaultDataSubId)).thenReturn(
- mDefaultDataSubscriptionInfo);
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
assertThat(mProviderModelSliceHelper.getMobileDrawable(drawable)).isEqualTo(
@@ -303,6 +293,16 @@
mNetworkCapabilities);
}
+ private void mockConnections(boolean isDataEnabled, int serviceState, String expectDisplayName,
+ int getDataState, boolean isWifiEnabled) {
+ when(mTelephonyManager.isDataEnabled()).thenReturn(isDataEnabled);
+ when(mWifiManager.isWifiEnabled()).thenReturn(isWifiEnabled);
+ when(mTelephonyManager.getDataState()).thenReturn(getDataState);
+
+ when(mServiceState.getState()).thenReturn(serviceState);
+ when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
+ }
+
private class TestCustomSliceable implements CustomSliceable {
TestCustomSliceable() {
}
diff --git a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
index 45f3693..0c8ffb9 100644
--- a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
@@ -74,7 +74,7 @@
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
- doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
+ doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
diff --git a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
index 6955dc4..a90c9bf 100644
--- a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -28,6 +28,7 @@
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
+import com.android.settings.fuelgauge.BatterySettingsFeatureProvider;
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
@@ -53,6 +54,7 @@
public final SupportFeatureProvider supportFeatureProvider;
public final MetricsFeatureProvider metricsFeatureProvider;
public final BatteryStatusFeatureProvider batteryStatusFeatureProvider;
+ public final BatterySettingsFeatureProvider batterySettingsFeatureProvider;
public final PowerUsageFeatureProvider powerUsageFeatureProvider;
public final DashboardFeatureProvider dashboardFeatureProvider;
public final DockUpdaterFeatureProvider dockUpdaterFeatureProvider;
@@ -92,6 +94,7 @@
supportFeatureProvider = mock(SupportFeatureProvider.class);
metricsFeatureProvider = mock(MetricsFeatureProvider.class);
batteryStatusFeatureProvider = mock(BatteryStatusFeatureProvider.class);
+ batterySettingsFeatureProvider = mock(BatterySettingsFeatureProvider.class);
powerUsageFeatureProvider = mock(PowerUsageFeatureProvider.class);
dashboardFeatureProvider = mock(DashboardFeatureProvider.class);
dockUpdaterFeatureProvider = mock(DockUpdaterFeatureProvider.class);
@@ -136,6 +139,11 @@
}
@Override
+ public BatterySettingsFeatureProvider getBatterySettingsFeatureProvider(Context context) {
+ return batterySettingsFeatureProvider;
+ }
+
+ @Override
public PowerUsageFeatureProvider getPowerUsageFeatureProvider(Context context) {
return powerUsageFeatureProvider;
}