Merge "Add Strings for Storage Settings" into sc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index eeb9694..6a4b8d5 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" />
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/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/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/values/strings.xml b/res/values/strings.xml
index ff5d737..2369864 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7054,6 +7054,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>
@@ -7061,6 +7063,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] -->
@@ -7498,6 +7503,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>
@@ -9570,6 +9577,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>
@@ -11526,6 +11536,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">
@@ -12821,10 +12850,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] -->
@@ -12970,8 +12995,8 @@
<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">Copy & paste notifications</string>
+ <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 or data you have copied</string>
+ <string name="show_clip_access_notification_summary">Show a message when apps access text, images, or other content you\u2019ve copied</string>
</resources>
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/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/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/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 1645590..68a0b03 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -298,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) {
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/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/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/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 7635733..cdc6537 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -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);
}
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/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/BatteryUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
index 775ca40..744db8c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
@@ -277,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))
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/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/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/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);