Merge "Make distinction between null and empty IM list."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index bf64ebe..6d35545 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2968,7 +2968,8 @@
<activity
android:name=".users.AddSupervisedUserActivity"
android:label="@*android:string/supervised_user_creation_label"
- android:icon="@drawable/ic_settings_multiuser">
+ android:icon="@drawable/ic_settings_multiuser"
+ android:exported="true">
</activity>
<activity
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 559a589..16658f8 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -2885,6 +2885,22 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" android:color="@color/accessibility_feature_background"/>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/drawable/ic_audio_description.xml"
+ line="22"
+ column="13"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" android:fillColor="@color/battery_good_color_light""
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
diff --git a/packages/apps/Settings/src/com/android/settings/dream/OWNERS b/packages/apps/Settings/src/com/android/settings/dream/OWNERS
new file mode 100644
index 0000000..56e1b39
--- /dev/null
+++ b/packages/apps/Settings/src/com/android/settings/dream/OWNERS
@@ -0,0 +1 @@
+lusilva@google.com
\ No newline at end of file
diff --git a/res/drawable/ic_audio_description.xml b/res/drawable/ic_audio_description.xml
new file mode 100644
index 0000000..0226582
--- /dev/null
+++ b/res/drawable/ic_audio_description.xml
@@ -0,0 +1,35 @@
+<!--
+ Copyright 2022 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.
+ -->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item>
+ <com.android.settingslib.widget.AdaptiveIconShapeDrawable
+ android:width="@dimen/accessibility_icon_size"
+ android:height="@dimen/accessibility_icon_size"
+ android:color="@color/accessibility_feature_background"/>
+ </item>
+ <item android:gravity="center">
+ <vector
+ android:width="@dimen/accessibility_icon_foreground_size"
+ android:height="@dimen/accessibility_icon_foreground_size"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M10,18v-4L8,14v-2q0,-1.65 1.175,-2.825Q10.35,8 12,8q1.65,0 2.825,1.175Q16,10.35 16,12v2h-2v4h2.8q0.5,0 0.85,-0.35t0.35,-0.85L18,12q0,-2.5 -1.75,-4.25T12,6Q9.5,6 7.75,7.75T6,12v4.8q0,0.5 0.35,0.85t0.85,0.35zM5,21q-0.825,0 -1.413,-0.587Q3,19.825 3,19L3,5q0,-0.825 0.587,-1.413Q4.175,3 5,3h14q0.825,0 1.413,0.587Q21,4.175 21,5v14q0,0.825 -0.587,1.413Q19.825,21 19,21zM5,19h14L19,5L5,5v14zM5,19L5,5v14z"/>
+ </vector>
+ </item>
+</layer-list>
\ No newline at end of file
diff --git a/res/layout/forgot_password_activity.xml b/res/layout/forgot_password_activity.xml
index ed1e2d2..7973251 100644
--- a/res/layout/forgot_password_activity.xml
+++ b/res/layout/forgot_password_activity.xml
@@ -32,6 +32,7 @@
<TextView
style="@style/SudDescription.Glif"
+ android:id="@+id/forgot_password_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a50c51a..0107358 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4983,6 +4983,9 @@
<!-- Summary text for keyboards when no layout has been selected. [CHAR LIMIT=35] -->
<string name="default_keyboard_layout">Default</string>
+ <!-- Title for the 'Speech' preference category. [CHAR LIMIT=45] -->
+ <string name="speech_category_title">Speech</string>
+
<!-- On Languages & input settings screen, setting summary. Setting for mouse pointer speed. [CHAR LIMIT=35] -->
<string name="pointer_speed">Pointer speed</string>
@@ -5499,7 +5502,7 @@
<!-- Used in the accessibility service settings to open the activity. [CHAR LIMIT=NONE] -->
<string name="accessibility_service_primary_open_title">Open <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
<!-- Used in the accessibility service settings to show quick settings tooltips. [CHAR LIMIT=NONE] -->
- <string name="accessibility_service_quick_settings_tooltips_content">Swipe down to quickly turn <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> on or off in quick settings</string>
+ <string name="accessibility_service_quick_settings_tooltips_content"><xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> added to Quick Settings. Swipe down to turn it on or off anytime.</string>
<!-- Used in the accessibility action for accessibility quick settings tooltips to dismiss. [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_tooltips_dismiss">Dismiss</string>
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
@@ -5554,6 +5557,13 @@
</plurals>
<!-- Title for the accessibility audio adjustment page. [CHAR LIMIT=50] -->
<string name="accessibility_audio_adjustment_title">Audio adjustment</string>
+ <!-- Title for control audio description preference. [CHAR LIMIT=50] -->
+ <string name="accessibility_toggle_audio_description_preference_title">Audio Description</string>
+ <!-- Summary for accessibility preference for audio description when need
+ audio description in adopted apps. [CHAR_LIMIT=NONE] -->
+ <string name="accessibility_audio_description_summary">Select audio sound track with audio description by default</string>
+ <!-- List of synonyms used in the settings search bar to find the "Audio Description. [CHAR LIMIT=NONE] -->
+ <string name="keywords_audio_description">audio description, audio, description, low vision,</string>
<!-- Preference's shortcut when enabled. [CHAR LIMIT=NONE] -->
<string name="accessibility_summary_shortcut_enabled">Shortcut on</string>
@@ -12032,20 +12042,44 @@
<!-- 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>
+ <!-- Top introduction on the financed device privacy settings, summarizing the changes a credit provider can make to a financed device. [CHAR LIMIT=NONE] -->
+ <string name="financed_privacy_intro">Your credit provider can change settings and install software on this device.\n\nIf you miss a payment, your device will be locked.\n\nTo learn more, contact your credit provider.</string>
+ <!-- Section header. This section shows what restrictions will be enforced on the device when it is financed. [CHAR LIMIT=60] -->
+ <string name="financed_privacy_restrictions_category">If your device is financed, you can\u2019t:</string>
+ <!-- Label explaining that installing apps from unknown sources beyond Play Store. [CHAR LIMIT=60]-->
+ <string name="financed_privacy_install_apps">Install apps from outside the Play Store</string>
+ <!-- Label explaining that rebooting the device into safe mode. [CHAR LIMIT=60]-->
+ <string name="financed_privacy_safe_mode">Reboot your device into safe mode</string>
+ <!-- Label explaining that adding more than one user into the device. [CHAR LIMIT=60]-->
+ <string name="financed_privacy_multi_users">Add multiple users to your device</string>
+ <!-- Label explaining that updating the date and time on the device. [CHAR LIMIT=60] -->
+ <string name="financed_privacy_config_date_time">Change date, time, and time zones</string>
+ <!-- Label explaining that turning on the developer options on the device. [CHAR LIMIT=40]-->
+ <string name="financed_privacy_developer_options">Use developer options</string>
+ <!-- Section header. This section shows how credit provider would control the device. [CHAR LIMIT=40]-->
+ <string name="financed_privacy_credit_provider_capabilities_category">Your credit provider can:</string>
+ <!-- Label explaining that IMEI can be access by the credit provider. [CHAR LIMIT=40] -->
+ <string name="financed_privacy_IMEI">Access your IMEI number</string>
+ <!-- Label explaining that device can be reset and data can be deleted. [CHAR LIMIT=40]-->
+ <string name="financed_privacy_factory_reset">Factory reset your device</string>
+ <!-- Section header. This section shows what the user can do if the device is locked by the credit provider. [CHAR LIMIT=100] -->
+ <string name="financed_privacy_locked_mode_category">If your device is locked, you can only use it to:</string>
+ <!-- Label explaining that calling emergency numbers. [CHAR LIMIT=40]-->
+ <string name="financed_privacy_emergency_calls">Make emergency calls</string>
+ <!-- Label explaining that access basic system level data including date, time, network status, and battery info. [CHAR LIMIT=100]-->
+ <string name="financed_privacy_system_info">View system info like date, time, network status, and battery</string>
+ <!-- Label explaining that powering on or off the device. [CHAR LIMIT=60]-->
+ <string name="financed_privacy_turn_on_off_device">Turn your device on or off</string>
+ <!-- Label explaining that accessing notifications and text messages. [CHAR LIMIT=60]-->
+ <string name="financed_privacy_notifications">View notifications & text messages</string>
+ <!-- Label explaining that using apps that are allowed to be used by the credit provider when the device is locked. [CHAR LIMIT=100]-->
+ <string name="financed_privacy_allowlisted_apps">Access apps that are allowed by the credit provider</string>
+ <!-- Section header. This sections shows what would happen if the device is fully paid. [CHAR LIMIT=60] -->
+ <string name="financed_privacy_fully_paid_category">Once you pay the full amount:</string>
+ <!-- Label explaining that all previously restrictions enforce by the credit provider will be revoked. [CHAR LIMIT=100]-->
+ <string name="financed_privacy_restrictions_removed">All restrictions are removed from the device</string>
+ <!-- Label explaining that the app installed by credit provider can be uninstalled. [CHAR LIMIT=60]-->
+ <string name="financed_privacy_uninstall_creditor_app">You can uninstall the creditor app</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] -->
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index dcf3fc2..fcdf47b 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -81,6 +81,16 @@
settings:keywords="@string/keywords_magnification"
settings:controller="com.android.settings.accessibility.MagnificationPreferenceController"/>
+ <SwitchPreference
+ android:key="toggle_audio_description"
+ android:persistent="false"
+ android:icon="@drawable/ic_audio_description"
+ android:summary="@string/accessibility_audio_description_summary"
+ android:title="@string/accessibility_toggle_audio_description_preference_title"
+ settings:keywords="@string/keywords_audio_description"
+ settings:searchable="true"
+ settings:controller="com.android.settings.accessibility.AudioDescriptionPreferenceController"/>
+
</PreferenceCategory>
<PreferenceCategory
diff --git a/res/xml/financed_privacy_settings.xml b/res/xml/financed_privacy_settings.xml
index 742d7e1..4e5a46a 100644
--- a/res/xml/financed_privacy_settings.xml
+++ b/res/xml/financed_privacy_settings.xml
@@ -19,66 +19,102 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/financed_privacy_settings">
- <PreferenceCategory android:key="exposure_category"
+ <com.android.settingslib.widget.TopIntroPreference
+ android:title="@string/financed_privacy_intro"
+ settings:searchable="false" />
+
+ <PreferenceCategory android:key="restrictions_category"
+ android:order="100"
+ android:title="@string/financed_privacy_restrictions_category"
+ android:contentDescription="@string/financed_privacy_restrictions_category">
+ <Preference android:key="financed_privacy_install_apps"
+ android:order="110"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_install_apps"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_safe_mode"
+ android:order="120"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_safe_mode"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_multi_users"
+ android:order="130"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_multi_users"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_config_date_time"
+ android:order="140"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_config_date_time"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_developer_options"
+ android:order="150"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_developer_options"
+ android:selectable="false" />
+ </PreferenceCategory>
+
+ <PreferenceCategory android:key="credit_provider_capabilities_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:title="@string/financed_privacy_credit_provider_capabilities_category"
+ android:contentDescription="@string/financed_privacy_credit_provider_capabilities_category">
+ <Preference android:key="financed_privacy_IMEI"
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:title="@string/financed_privacy_IMEI"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_factory_reset"
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"/>
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_factory_reset"
+ android:selectable="false" />
</PreferenceCategory>
- <PreferenceCategory android:title="@string/financed_privacy_exposure_changes_category"
+ <PreferenceCategory android:key="locked_mode_category"
android:order="300"
- android:key="exposure_changes_category">
- <Preference android:fragment="com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages"
+ android:title="@string/financed_privacy_locked_mode_category"
+ android:contentDescription="@string/financed_privacy_locked_mode_category">
+ <Preference android:key="financed_privacy_emergency_calls"
android:order="310"
- android:key="number_enterprise_installed_packages"
- android:title="@string/enterprise_privacy_enterprise_installed_packages"/>
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_emergency_calls"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_system_info"
+ android:order="320"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_system_info"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_turn_on_off_device"
+ android:order="330"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_turn_on_off_device"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_notifications"
+ android:order="340"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_notifications"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_allowlisted_apps"
+ android:order="350"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_allowlisted_apps"
+ android:selectable="false" />
</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 android:key="fully_paid_category"
+ android:order="400"
+ android:title="@string/financed_privacy_fully_paid_category"
+ android:contentDescription="@string/financed_privacy_fully_paid_category">
+ <Preference android:key="financed_privacy_restrictions_removed"
+ android:order="410"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_restrictions_removed"
+ android:selectable="false" />
+ <Preference android:key="financed_privacy_uninstall_creditor_app"
+ android:order="420"
+ android:layout_height="wrap_content"
+ android:title="@string/financed_privacy_uninstall_creditor_app"
+ 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/interact_across_profiles_permissions_details.xml b/res/xml/interact_across_profiles_permissions_details.xml
index bf0ea8f..2e0f3d8 100644
--- a/res/xml/interact_across_profiles_permissions_details.xml
+++ b/res/xml/interact_across_profiles_permissions_details.xml
@@ -32,10 +32,12 @@
android:key="interact_across_profiles_settings_switch" />
<Preference
+ android:key="interact_across_profiles_summary_1"
android:summary="@string/interact_across_profiles_summary_1"
android:selectable="false" />
<Preference
+ android:key="interact_across_profiles_summary_2"
android:summary="@string/interact_across_profiles_summary_2"
android:selectable="false" />
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index f2b6d8a..c99d591 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -38,8 +38,6 @@
android:name="classname"
android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
</Preference>
-
-
</PreferenceCategory>
<PreferenceCategory
@@ -50,6 +48,7 @@
android:title="@string/virtual_keyboard_category"
android:fragment="com.android.settings.inputmethod.AvailableVirtualKeyboardFragment"
settings:keywords="@string/keywords_virtual_keyboard"/>
+
<Preference
android:key="physical_keyboard_pref"
android:title="@string/physical_keyboard_title"
@@ -58,6 +57,21 @@
</PreferenceCategory>
<PreferenceCategory
+ android:key="speech_category"
+ android:title="@string/speech_category_title">
+ <com.android.settings.widget.GearPreference
+ android:key="voice_input_settings"
+ android:title="@string/voice_input_settings_title"
+ android:fragment="com.android.settings.language.DefaultVoiceInputPicker" />
+
+ <Preference
+ android:key="tts_settings_summary"
+ android:title="@string/tts_settings_title"
+ android:fragment="com.android.settings.tts.TextToSpeechSettings"
+ settings:searchable="false"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory
android:key="input_assistance_category"
android:title="@string/input_assistance">
<!-- Spell checker preference title, summary and fragment will be set programmatically. -->
@@ -79,20 +93,12 @@
</PreferenceCategory>
<PreferenceCategory
- android:key="pointer_and_tts_category"
+ android:key="pointer_category"
android:layout="@layout/preference_category_no_label">
-
<com.android.settings.PointerSpeedPreference
android:key="pointer_speed"
android:title="@string/pointer_speed"
android:dialogTitle="@string/pointer_speed" />
-
- <Preference
- android:key="tts_settings_summary"
- android:title="@string/tts_settings_title"
- android:fragment="com.android.settings.tts.TextToSpeechSettings"
- settings:searchable="false"/>
-
</PreferenceCategory>
<SwitchPreference
diff --git a/res/xml/manage_assist.xml b/res/xml/manage_assist.xml
index 59ba2f5..c8dbe42 100644
--- a/res/xml/manage_assist.xml
+++ b/res/xml/manage_assist.xml
@@ -49,11 +49,6 @@
android:title="@string/assist_flash_title"
android:summary="@string/assist_flash_summary" />
- <com.android.settings.widget.GearPreference
- android:key="voice_input_settings"
- android:title="@string/voice_input_settings_title"
- android:fragment="com.android.settings.applications.assist.DefaultVoiceInputPicker" />
-
<com.android.settingslib.widget.FooterPreference
android:key="manage_assist_footer"
android:title="@string/assist_footer"
diff --git a/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java b/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java
index f9b537b..5fc4cd2 100644
--- a/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java
@@ -221,6 +221,13 @@
extras.putString(AccessibilitySettings.EXTRA_SETTINGS_COMPONENT_NAME,
new ComponentName(packageName, settingsClassName).flattenToString());
}
+
+ final String tileServiceClassName = info.getTileServiceClassName();
+ if (!TextUtils.isEmpty(tileServiceClassName)) {
+ extras.putString(AccessibilitySettings.EXTRA_TILE_SERVICE_COMPONENT_NAME,
+ new ComponentName(packageName, tileServiceClassName).flattenToString());
+ }
+
extras.putParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME, componentName);
extras.putInt(AccessibilitySettings.EXTRA_ANIMATED_IMAGE_RES, info.getAnimatedImageRes());
diff --git a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
index 0ca16cb..773c987 100644
--- a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
+++ b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
@@ -46,6 +46,7 @@
import androidx.annotation.DrawableRes;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
@@ -125,9 +126,15 @@
}
static AlertDialog createAccessibilityTutorialDialog(Context context, int shortcutTypes) {
+ return createAccessibilityTutorialDialog(context, shortcutTypes, mOnClickListener);
+ }
+
+ static AlertDialog createAccessibilityTutorialDialog(Context context, int shortcutTypes,
+ @Nullable DialogInterface.OnClickListener negativeButtonListener) {
return new AlertDialog.Builder(context)
.setView(createShortcutNavigationContentView(context, shortcutTypes))
- .setNegativeButton(R.string.accessibility_tutorial_dialog_button, mOnClickListener)
+ .setNegativeButton(R.string.accessibility_tutorial_dialog_button,
+ negativeButtonListener)
.create();
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index b712b9d..e834640 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -97,6 +97,7 @@
static final String EXTRA_SETTINGS_TITLE = "settings_title";
static final String EXTRA_COMPONENT_NAME = "component_name";
static final String EXTRA_SETTINGS_COMPONENT_NAME = "settings_component_name";
+ static final String EXTRA_TILE_SERVICE_COMPONENT_NAME = "tile_service_component_name";
static final String EXTRA_VIDEO_RAW_RESOURCE_ID = "video_resource";
static final String EXTRA_LAUNCHED_FROM_SUW = "from_suw";
static final String EXTRA_ANIMATED_IMAGE_RES = "animated_image_res";
@@ -573,11 +574,13 @@
serviceEnabled);
final String htmlDescription = info.loadHtmlDescription(mPm);
final String settingsClassName = info.getSettingsActivityName();
+ final String tileServiceClassName = info.getTileServiceClassName();
putBasicExtras(preference, prefKey, title, description, imageRes, htmlDescription,
componentName);
putServiceExtras(preference, resolveInfo, serviceEnabled);
putSettingsExtras(preference, packageName, settingsClassName);
+ putTileServiceExtras(preference, packageName, tileServiceClassName);
preferenceList.add(preference);
}
@@ -631,10 +634,13 @@
final int imageRes = info.getAnimatedImageRes();
final String htmlDescription = info.loadHtmlDescription(mPm);
final String settingsClassName = info.getSettingsActivityName();
+ final String tileServiceClassName = info.getTileServiceClassName();
putBasicExtras(preference, prefKey, title, description, imageRes, htmlDescription,
componentName);
putSettingsExtras(preference, componentName.getPackageName(), settingsClassName);
+ putTileServiceExtras(preference, componentName.getPackageName(),
+ tileServiceClassName);
preferenceList.add(preference);
}
@@ -730,7 +736,11 @@
/**
* Puts the service extras into {@link RestrictedPreference}'s getExtras().
*
- * Called by {@link AccessibilityServiceInfo} for now.
+ * <p><b>Note:</b> Called by {@link AccessibilityServiceInfo}.</p>
+ *
+ * @param preference The preference we are configuring.
+ * @param resolveInfo The service resolve info.
+ * @param serviceEnabled Whether the accessibility service is enabled.
*/
private void putServiceExtras(RestrictedPreference preference, ResolveInfo resolveInfo,
Boolean serviceEnabled) {
@@ -743,7 +753,12 @@
/**
* Puts the settings extras into {@link RestrictedPreference}'s getExtras().
*
- * Called when settings UI is needed.
+ * <p><b>Note:</b> Called when settings UI is needed.</p>
+ *
+ * @param preference The preference we are configuring.
+ * @param packageName Package of accessibility feature.
+ * @param settingsClassName The component name of an activity that allows the user to modify
+ * the settings for this accessibility feature.
*/
private void putSettingsExtras(RestrictedPreference preference, String packageName,
String settingsClassName) {
@@ -756,5 +771,27 @@
new ComponentName(packageName, settingsClassName).flattenToString());
}
}
+
+ /**
+ * Puts the information about a particular application
+ * {@link android.service.quicksettings.TileService} into {@link RestrictedPreference}'s
+ * getExtras().
+ *
+ * <p><b>Note:</b> Called when a tooltip of
+ * {@link android.service.quicksettings.TileService} is needed.</p>
+ *
+ * @param preference The preference we are configuring.
+ * @param packageName Package of accessibility feature.
+ * @param tileServiceClassName The component name of tileService is associated with this
+ * accessibility feature.
+ */
+ private void putTileServiceExtras(RestrictedPreference preference, String packageName,
+ String tileServiceClassName) {
+ final Bundle extras = preference.getExtras();
+ if (!TextUtils.isEmpty(tileServiceClassName)) {
+ extras.putString(EXTRA_TILE_SERVICE_COMPONENT_NAME,
+ new ComponentName(packageName, tileServiceClassName).flattenToString());
+ }
+ }
}
}
diff --git a/src/com/android/settings/accessibility/AudioDescriptionPreferenceController.java b/src/com/android/settings/accessibility/AudioDescriptionPreferenceController.java
new file mode 100644
index 0000000..a05a0d0
--- /dev/null
+++ b/src/com/android/settings/accessibility/AudioDescriptionPreferenceController.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2022 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 static android.provider.Settings.Secure.ENABLED_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT;
+
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * A toggle preference controller for audio description
+ */
+public class AudioDescriptionPreferenceController extends TogglePreferenceController {
+
+ static final String PREF_KEY = "toggle_audio_description";
+
+ public AudioDescriptionPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ ENABLED_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT,
+ OFF /* default */,
+ UserHandle.USER_CURRENT) == ON;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putIntForUser(mContext.getContentResolver(),
+ ENABLED_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT,
+ isChecked ? ON : OFF,
+ UserHandle.USER_CURRENT);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_accessibility;
+ }
+}
diff --git a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
index 00f2804..ce8db21 100644
--- a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
@@ -20,9 +20,11 @@
import android.accessibilityservice.AccessibilityShortcutInfo;
import android.app.ActivityOptions;
+import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.ContentResolver;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
@@ -51,6 +53,7 @@
private static final String TAG = "LaunchA11yActivity";
private static final String EMPTY_STRING = "";
protected static final String KEY_LAUNCH_PREFERENCE = "launch_preference";
+ private ComponentName mTileComponentName;
@Override
public int getMetricsCategory() {
@@ -106,6 +109,13 @@
AccessibilitySettings.EXTRA_SETTINGS_TITLE);
mSettingsIntent = TextUtils.isEmpty(settingsTitle) ? null : getSettingsIntent(arguments);
mSettingsTitle = (mSettingsIntent == null) ? null : settingsTitle;
+
+ // Tile service.
+ if (arguments.containsKey(AccessibilitySettings.EXTRA_TILE_SERVICE_COMPONENT_NAME)) {
+ final String tileServiceComponentName = arguments.getString(
+ AccessibilitySettings.EXTRA_TILE_SERVICE_COMPONENT_NAME);
+ mTileComponentName = ComponentName.unflattenFromString(tileServiceComponentName);
+ }
}
@Override
@@ -116,12 +126,30 @@
@Override
ComponentName getTileComponentName() {
- return null;
+ return mTileComponentName;
}
@Override
CharSequence getTileName() {
- return null;
+ final ComponentName componentName = getTileComponentName();
+ if (componentName == null) {
+ return null;
+ }
+ return loadTileLabel(getPrefContext(), componentName);
+ }
+
+ @Override
+ public Dialog onCreateDialog(int dialogId) {
+ switch (dialogId) {
+ case AccessibilityDialogUtils.DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
+ final Dialog dialog = AccessibilityGestureNavigationTutorial
+ .createAccessibilityTutorialDialog(getPrefContext(),
+ getUserShortcutTypes(), this::callOnTutorialDialogButtonClicked);
+ dialog.setCanceledOnTouchOutside(false);
+ return dialog;
+ default:
+ return super.onCreateDialog(dialogId);
+ }
}
@Override
@@ -208,4 +236,22 @@
return settingsIntent;
}
+
+ /**
+ * This method will be invoked when a button in the tutorial dialog is clicked.
+ *
+ * @param dialog The dialog that received the click
+ * @param which The button that was clicked
+ */
+ private void callOnTutorialDialogButtonClicked(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ showQuickSettingsTooltipIfNeeded();
+ }
+
+
+ @Override
+ protected void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
+ super.callOnAlertDialogCheckboxClicked(dialog, which);
+ showQuickSettingsTooltipIfNeeded(getShortcutTypeCheckBoxValue());
+ }
}
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index a1c98cd..d7a506a 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -65,6 +65,7 @@
private static final String EMPTY_STRING = "";
private Dialog mWarningDialog;
+ private ComponentName mTileComponentName;
private BroadcastReceiver mPackageRemovedReceiver;
private boolean mDisabledStateLogged = false;
private long mStartTimeMillsForLogging = 0;
@@ -168,9 +169,9 @@
@Override
public Dialog onCreateDialog(int dialogId) {
+ final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
switch (dialogId) {
- case DialogEnums.ENABLE_WARNING_FROM_TOGGLE: {
- final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
+ case DialogEnums.ENABLE_WARNING_FROM_TOGGLE:
if (info == null) {
return null;
}
@@ -178,10 +179,8 @@
.createCapabilitiesDialog(getPrefContext(), info,
this::onDialogButtonFromEnableToggleClicked,
this::onDialogButtonFromUninstallClicked);
- break;
- }
- case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE: {
- final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
+ return mWarningDialog;
+ case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE:
if (info == null) {
return null;
}
@@ -189,10 +188,8 @@
.createCapabilitiesDialog(getPrefContext(), info,
this::onDialogButtonFromShortcutToggleClicked,
this::onDialogButtonFromUninstallClicked);
- break;
- }
- case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT: {
- final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
+ return mWarningDialog;
+ case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT:
if (info == null) {
return null;
}
@@ -200,23 +197,24 @@
.createCapabilitiesDialog(getPrefContext(), info,
this::onDialogButtonFromShortcutClicked,
this::onDialogButtonFromUninstallClicked);
- break;
- }
- case DialogEnums.DISABLE_WARNING_FROM_TOGGLE: {
- final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
+ return mWarningDialog;
+ case DialogEnums.DISABLE_WARNING_FROM_TOGGLE:
if (info == null) {
return null;
}
mWarningDialog = AccessibilityServiceWarning
.createDisableDialog(getPrefContext(), info,
this::onDialogButtonFromDisableToggleClicked);
- break;
- }
- default: {
- mWarningDialog = super.onCreateDialog(dialogId);
- }
+ return mWarningDialog;
+ case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
+ final Dialog dialog = AccessibilityGestureNavigationTutorial
+ .createAccessibilityTutorialDialog(getPrefContext(),
+ getUserShortcutTypes(), this::callOnTutorialDialogButtonClicked);
+ dialog.setCanceledOnTouchOutside(false);
+ return dialog;
+ default:
+ return super.onCreateDialog(dialogId);
}
- return mWarningDialog;
}
@Override
@@ -243,12 +241,16 @@
@Override
ComponentName getTileComponentName() {
- return null;
+ return mTileComponentName;
}
@Override
CharSequence getTileName() {
- return null;
+ final ComponentName componentName = getTileComponentName();
+ if (componentName == null) {
+ return null;
+ }
+ return loadTileLabel(getPrefContext(), componentName);
}
@Override
@@ -386,6 +388,12 @@
mPackageName = getAccessibilityServiceInfo().getResolveInfo().loadLabel(
getPackageManager());
+ if (arguments.containsKey(AccessibilitySettings.EXTRA_TILE_SERVICE_COMPONENT_NAME)) {
+ final String tileServiceComponentName = arguments.getString(
+ AccessibilitySettings.EXTRA_TILE_SERVICE_COMPONENT_NAME);
+ mTileComponentName = ComponentName.unflattenFromString(tileServiceComponentName);
+ }
+
mStartTimeMillsForLogging = arguments.getLong(AccessibilitySettings.EXTRA_TIME_FOR_LOGGING);
}
@@ -488,6 +496,23 @@
mWarningDialog.dismiss();
}
+ /**
+ * This method will be invoked when a button in the tutorial dialog is clicked.
+ *
+ * @param dialog The dialog that received the click
+ * @param which The button that was clicked
+ */
+ private void callOnTutorialDialogButtonClicked(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ showQuickSettingsTooltipIfNeeded();
+ }
+
+ @Override
+ protected void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
+ super.callOnAlertDialogCheckboxClicked(dialog, which);
+ showQuickSettingsTooltipIfNeeded(getShortcutTypeCheckBoxValue());
+ }
+
void onDialogButtonFromShortcutClicked(View view) {
final int viewId = view.getId();
if (viewId == R.id.permission_enable_allow_button) {
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 0cc1f1c..08e9b88 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -25,7 +25,9 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
import android.graphics.drawable.Drawable;
import android.icu.text.CaseMap;
import android.net.Uri;
@@ -33,6 +35,7 @@
import android.os.Handler;
import android.os.UserHandle;
import android.provider.Settings;
+import android.service.quicksettings.TileService;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
@@ -799,6 +802,19 @@
}
/**
+ * Shows the quick settings tooltip if the quick settings service and the shortcut are assigned.
+ * The tooltip only shows once.
+ *
+ * @param shortcutType The shortcut type.
+ */
+ protected void showQuickSettingsTooltipIfNeeded(@UserShortcutType int shortcutType) {
+ if (shortcutType == AccessibilityUtil.UserShortcutType.EMPTY) {
+ return;
+ }
+ showQuickSettingsTooltipIfNeeded();
+ }
+
+ /**
* Shows the quick settings tooltip if the quick settings service is assigned. The tooltip only
* shows once.
*/
@@ -830,4 +846,20 @@
tileComponentName);
mNeedsQSTooltipReshow = false;
}
+
+ /** Returns user visible name of the tile by given {@link ComponentName}. */
+ protected CharSequence loadTileLabel(Context context, ComponentName componentName) {
+ final PackageManager packageManager = context.getPackageManager();
+ final Intent queryIntent = new Intent(TileService.ACTION_QS_TILE);
+ final List<ResolveInfo> resolveInfos =
+ packageManager.queryIntentServices(queryIntent, PackageManager.GET_META_DATA);
+ for (ResolveInfo info : resolveInfos) {
+ final ServiceInfo serviceInfo = info.serviceInfo;
+ if (TextUtils.equals(componentName.getPackageName(), serviceInfo.packageName)
+ && TextUtils.equals(componentName.getClassName(), serviceInfo.name)) {
+ return serviceInfo.loadLabel(packageManager);
+ }
+ }
+ return null;
+ }
}
diff --git a/src/com/android/settings/accounts/ManagedProfileSettings.java b/src/com/android/settings/accounts/ManagedProfileSettings.java
index a6fa15a..001a2cd 100644
--- a/src/com/android/settings/accounts/ManagedProfileSettings.java
+++ b/src/com/android/settings/accounts/ManagedProfileSettings.java
@@ -16,6 +16,12 @@
package com.android.settings.accounts;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CROSS_PROFILE_CALENDAR_SUMMARY;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CROSS_PROFILE_CALENDAR_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONTACT_SEARCH_SUMMARY;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONTACT_SEARCH_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SETTING;
+
import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -78,6 +84,17 @@
super.onCreate(icicle);
mManagedProfileBroadcastReceiver = new ManagedProfileBroadcastReceiver();
mManagedProfileBroadcastReceiver.register(getActivity());
+ replaceEnterpriseStringTitle("work_mode",
+ WORK_PROFILE_SETTING, R.string.work_mode_label);
+ replaceEnterpriseStringTitle("contacts_search",
+ WORK_PROFILE_CONTACT_SEARCH_TITLE, R.string.managed_profile_contact_search_title);
+ replaceEnterpriseStringSummary("contacts_search",
+ WORK_PROFILE_CONTACT_SEARCH_SUMMARY,
+ R.string.managed_profile_contact_search_summary);
+ replaceEnterpriseStringTitle("cross_profile_calendar",
+ CROSS_PROFILE_CALENDAR_TITLE, R.string.cross_profile_calendar_title);
+ replaceEnterpriseStringSummary("cross_profile_calendar",
+ CROSS_PROFILE_CALENDAR_SUMMARY, R.string.cross_profile_calendar_summary);
}
@Override
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index a38ed11..5bc4118 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -16,6 +16,8 @@
package com.android.settings.applications.appinfo;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECTED_WORK_AND_PERSONAL_APPS_TITLE;
+
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.Activity;
@@ -238,6 +240,8 @@
startListeningToPackageRemove();
setHasOptionsMenu(true);
+ replaceEnterpriseStringTitle("interact_across_profiles",
+ CONNECTED_WORK_AND_PERSONAL_APPS_TITLE, R.string.interact_across_profiles_title);
}
@Override
diff --git a/src/com/android/settings/applications/appinfo/OWNERS b/src/com/android/settings/applications/appinfo/OWNERS
new file mode 100644
index 0000000..cd6abb8
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/OWNERS
@@ -0,0 +1,5 @@
+# just for per-app locale settings review
+allenwtsu@google.com
+danielwbhuang@google.com
+goldmanj@google.com
+tomhsu@google.com
diff --git a/src/com/android/settings/applications/assist/ManageAssist.java b/src/com/android/settings/applications/assist/ManageAssist.java
index c96f43f..ad6c71e 100644
--- a/src/com/android/settings/applications/assist/ManageAssist.java
+++ b/src/com/android/settings/applications/assist/ManageAssist.java
@@ -73,7 +73,6 @@
controllers.add(new AssistContextPreferenceController(context, lifecycle));
controllers.add(new AssistScreenshotPreferenceController(context, lifecycle));
controllers.add(new AssistFlashScreenPreferenceController(context, lifecycle));
- controllers.add(new DefaultVoiceInputPreferenceController(context, lifecycle));
return controllers;
}
diff --git a/src/com/android/settings/applications/specialaccess/SpecialAccessSettings.java b/src/com/android/settings/applications/specialaccess/SpecialAccessSettings.java
index f96ff63..2cbc304 100644
--- a/src/com/android/settings/applications/specialaccess/SpecialAccessSettings.java
+++ b/src/com/android/settings/applications/specialaccess/SpecialAccessSettings.java
@@ -16,7 +16,11 @@
package com.android.settings.applications.specialaccess;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECTED_WORK_AND_PERSONAL_APPS_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGE_DEVICE_ADMIN_APPS;
+
import android.app.settings.SettingsEnums;
+import android.os.Bundle;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -34,6 +38,15 @@
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ replaceEnterpriseStringTitle("interact_across_profiles",
+ CONNECTED_WORK_AND_PERSONAL_APPS_TITLE, R.string.interact_across_profiles_title);
+ replaceEnterpriseStringTitle("device_administrators",
+ MANAGE_DEVICE_ADMIN_APPS, R.string.manage_device_admin);
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.special_access;
}
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
index e133c62..de79739 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
@@ -27,6 +27,8 @@
import static android.app.admin.DevicePolicyResources.Strings.Settings.REMOVE_DEVICE_ADMIN;
import static android.app.admin.DevicePolicyResources.Strings.Settings.REMOVE_WORK_PROFILE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.SET_PROFILE_OWNER_DIALOG_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.SET_PROFILE_OWNER_POSTSETUP_WARNING;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.UNINSTALL_DEVICE_ADMIN;
import static android.app.admin.DevicePolicyResources.Strings.Settings.USER_ADMIN_POLICIES_WARNING;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_ADMIN_POLICIES_WARNING;
@@ -309,11 +311,13 @@
return;
}
- // othewise, only the defined default supervision profile owner can be set after user
- // setup.
+ // otherwise, only the defined default supervision profile owner or holder of
+ // supersvision role can be set after user setup.
final String supervisor = getString(
com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent);
- if (TextUtils.isEmpty(supervisor)) {
+ final String supervisionRolePackage = getString(
+ com.android.internal.R.string.config_systemSupervision);
+ if (TextUtils.isEmpty(supervisor) && TextUtils.isEmpty(supervisionRolePackage)) {
Log.w(TAG, "Unable to set profile owner post-setup, no default supervisor"
+ "profile owner defined");
finish();
@@ -322,7 +326,8 @@
final ComponentName supervisorComponent = ComponentName.unflattenFromString(
supervisor);
- if (supervisorComponent == null || who.compareTo(supervisorComponent) != 0) {
+ if (!who.equals(supervisorComponent)
+ && !who.getPackageName().equals(supervisionRolePackage)) {
Log.w(TAG, "Unable to set non-default profile owner post-setup " + who);
finish();
return;
@@ -365,6 +370,10 @@
mAdminDescription = (TextView)findViewById(R.id.admin_description);
mProfileOwnerWarning = (TextView) findViewById(R.id.profile_owner_warning);
+ mProfileOwnerWarning.setText(
+ mDPM.getString(SET_PROFILE_OWNER_POSTSETUP_WARNING,
+ () -> getString(R.string.adding_profile_owner_warning)));
+
mAddMsg = (TextView)findViewById(R.id.add_msg);
mAddMsgExpander = (ImageView) findViewById(R.id.add_msg_expander);
final View.OnClickListener onClickListener = new View.OnClickListener() {
@@ -410,6 +419,8 @@
});
mUninstallButton = (Button) findViewById(R.id.uninstall_button);
+ mUninstallButton.setText(mDPM.getString(UNINSTALL_DEVICE_ADMIN,
+ () -> getString(R.string.uninstall_device_admin)));
mUninstallButton.setFilterTouchesWhenObscured(true);
mUninstallButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminSettings.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminSettings.java
index 4a99073..3819124 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminSettings.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminSettings.java
@@ -16,7 +16,10 @@
package com.android.settings.applications.specialaccess.deviceadmin;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.NO_DEVICE_ADMINS;
+
import android.app.settings.SettingsEnums;
+import android.os.Bundle;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -32,6 +35,14 @@
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ // TODO: Replace PreferenceScreen title manage_device_admin/MANAGE_DEVICE_ADMIN_APPS
+ replaceEnterpriseStringTitle("device_admin_footer",
+ NO_DEVICE_ADMINS, R.string.no_device_admins);
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.device_admin_settings;
}
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
index 4e96aa3..e85a513 100644
--- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
@@ -17,9 +17,13 @@
import static android.app.admin.DevicePolicyResources.Strings.Settings.APP_CAN_ACCESS_PERSONAL_DATA;
import static android.app.admin.DevicePolicyResources.Strings.Settings.APP_CAN_ACCESS_PERSONAL_PERMISSIONS;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECTED_APPS_SHARE_PERMISSIONS_AND_DATA;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECT_APPS_DIALOG_SUMMARY;
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECT_APPS_DIALOG_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.HOW_TO_DISCONNECT_APPS;
import static android.app.admin.DevicePolicyResources.Strings.Settings.INSTALL_IN_PERSONAL_PROFILE_TO_CONNECT_PROMPT;
import static android.app.admin.DevicePolicyResources.Strings.Settings.INSTALL_IN_WORK_PROFILE_TO_CONNECT_PROMPT;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ONLY_CONNECT_TRUSTED_APPS;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
import static android.provider.Settings.ACTION_MANAGE_CROSS_PROFILE_ACCESS;
@@ -46,6 +50,7 @@
import android.os.UserManager;
import android.stats.devicepolicy.DevicePolicyEnums;
import android.util.IconDrawableFactory;
+import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -72,9 +77,11 @@
"interact_across_profiles_extra_summary";
public static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
public static final String INTENT_KEY = "intent";
+ private static final String TAG = "InteractAcrossProfilesDetails";
private Context mContext;
private CrossProfileApps mCrossProfileApps;
+ private DevicePolicyManager mDevicePolicyManager;
private UserManager mUserManager;
private RestrictedSwitchPreference mSwitchPref;
private LayoutPreference mHeader;
@@ -94,6 +101,7 @@
mContext = getContext();
mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class);
+ mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
mUserManager = mContext.getSystemService(UserManager.class);
mPackageManager = mContext.getPackageManager();
@@ -106,6 +114,18 @@
mInstallAppIntent = AppStoreUtil.getAppStoreLink(mContext, mPackageName);
addPreferencesFromResource(R.xml.interact_across_profiles_permissions_details);
+
+ replaceEnterpriseStringSummary("interact_across_profiles_summary_1",
+ CONNECTED_APPS_SHARE_PERMISSIONS_AND_DATA,
+ R.string.interact_across_profiles_summary_1);
+ replaceEnterpriseStringSummary("interact_across_profiles_summary_2",
+ ONLY_CONNECT_TRUSTED_APPS,
+ R.string.interact_across_profiles_summary_2);
+ replaceEnterpriseStringSummary("interact_across_profiles_extra_summary",
+ HOW_TO_DISCONNECT_APPS,
+ R.string.interact_across_profiles_summary_3);
+
+
mSwitchPref = findPreference(INTERACT_ACROSS_PROFILES_SETTINGS_SWITCH);
mSwitchPref.setOnPreferenceClickListener(this);
@@ -127,6 +147,19 @@
logPageLaunchMetrics();
}
+ private void replaceEnterpriseStringSummary(
+ String preferenceKey, String overrideKey, int resource) {
+ Preference preference = findPreference(preferenceKey);
+ if (preference == null) {
+ Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
+ return;
+ }
+
+ preference.setSummary(
+ mDevicePolicyManager.getString(overrideKey,
+ () -> getString(resource)));
+ }
+
private void maybeShowExtraSummary() {
Preference extraSummary = findPreference(INTERACT_ACROSS_PROFILE_EXTRA_SUMMARY_KEY);
if (extraSummary == null) {
@@ -264,7 +297,8 @@
final TextView dialogTitle = dialogView.findViewById(
R.id.interact_across_profiles_consent_dialog_title);
dialogTitle.setText(mDpm.getString(CONNECT_APPS_DIALOG_TITLE, () ->
- getString(R.string.interact_across_profiles_consent_dialog_title, mAppLabel)));
+ getString(R.string.interact_across_profiles_consent_dialog_title, mAppLabel),
+ mAppLabel));
final TextView appDataSummary = dialogView.findViewById(R.id.app_data_summary);
appDataSummary.setText(
@@ -280,6 +314,12 @@
mAppLabel),
mAppLabel));
+ final TextView dialogSummary =
+ dialogView.findViewById(R.id.interact_across_profiles_consent_dialog_summary);
+ dialogSummary.setText(mDpm.getString(CONNECT_APPS_DIALOG_SUMMARY,
+ () -> getString(
+ R.string.interact_across_profiles_consent_dialog_summary)));
+
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(dialogView)
.setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingController.java b/src/com/android/settings/bluetooth/BluetoothPairingController.java
index b75e02a..c70a56a 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingController.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingController.java
@@ -435,7 +435,7 @@
*/
public void onCancel() {
Log.d(TAG, "Pairing dialog canceled");
- mDevice.cancelPairing();
+ mDevice.cancelBondProcess();
}
/**
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java
index bc5dc66..9883e61 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingService.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java
@@ -98,7 +98,7 @@
} else if (action.equals(ACTION_DISMISS_PAIRING)) {
Log.d(TAG, "Notification cancel " + " (" +
mDevice.getName() + ")");
- mDevice.cancelPairing();
+ mDevice.cancelBondProcess();
} else {
int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
BluetoothDevice.ERROR);
@@ -144,7 +144,7 @@
createPairingNotification(intent);
} else if (TextUtils.equals(action, ACTION_DISMISS_PAIRING)) {
Log.d(TAG, "Notification cancel " + " (" + mDevice.getName() + ")");
- mDevice.cancelPairing();
+ mDevice.cancelBondProcess();
mNm.cancel(NOTIFICATION_ID);
stopSelf();
} else if (TextUtils.equals(action, ACTION_PAIRING_DIALOG)) {
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index e38d843..cfdfdaa 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -16,6 +16,7 @@
package com.android.settings.dashboard;
import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.ContentResolver;
import android.content.Context;
@@ -79,6 +80,7 @@
private DashboardTilePlaceholderPreferenceController mPlaceholderPreferenceController;
private boolean mListeningToCategoryChange;
private List<String> mSuppressInjectedTileKeys;
+ private DevicePolicyManager mDevicePolicyManager;
@Override
public void onAttach(Context context) {
@@ -148,6 +150,7 @@
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ mDevicePolicyManager = getSystemService(DevicePolicyManager.class);
// Set ComparisonCallback so we get better animation when list changes.
getPreferenceManager().setPreferenceComparisonCallback(
new PreferenceManager.SimplePreferenceComparisonCallback());
@@ -566,4 +569,30 @@
resolver.unregisterContentObserver(observer);
});
}
+
+ protected void replaceEnterpriseStringTitle(
+ String preferenceKey, String overrideKey, int resource) {
+ Preference preference = findPreference(preferenceKey);
+ if (preference == null) {
+ Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
+ return;
+ }
+
+ preference.setTitle(
+ mDevicePolicyManager.getString(overrideKey,
+ () -> getString(resource)));
+ }
+
+ protected void replaceEnterpriseStringSummary(
+ String preferenceKey, String overrideKey, int resource) {
+ Preference preference = findPreference(preferenceKey);
+ if (preference == null) {
+ Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
+ return;
+ }
+
+ preference.setSummary(
+ mDevicePolicyManager.getString(overrideKey,
+ () -> getString(resource)));
+ }
}
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
index 1b3b47a..fe20a01 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -123,13 +123,13 @@
mDataUsageController = null;
}
- private void updateConfiguration(Context context,
+ protected void updateConfiguration(Context context,
int subscriptionId, SubscriptionInfo subInfo) {
final NetworkPolicyManager policyManager =
context.getSystemService(NetworkPolicyManager.class);
mPolicyEditor = new NetworkPolicyEditor(policyManager);
- mDataUsageController = new DataUsageController(context);
+ mDataUsageController = createDataUsageController(context);
mDataUsageController.setSubscriptionId(subscriptionId);
mDataInfoController = new DataUsageInfoController();
@@ -146,6 +146,11 @@
}
@VisibleForTesting
+ DataUsageController createDataUsageController(Context context) {
+ return new DataUsageController(context);
+ }
+
+ @VisibleForTesting
DataUsageSummaryPreferenceController(
DataUsageController dataUsageController,
DataUsageInfoController dataInfoController,
@@ -186,8 +191,7 @@
.getSubscriptionPlans(subscriptionId);
}
- @VisibleForTesting
- SubscriptionInfo getSubscriptionInfo(int subscriptionId) {
+ protected SubscriptionInfo getSubscriptionInfo(int subscriptionId) {
if (!mHasMobileData) {
return null;
}
diff --git a/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java b/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java
index cd26ed1..ceba8be 100644
--- a/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java
+++ b/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java
@@ -88,7 +88,7 @@
@Override
protected void onClick() {
- if (mDataUsageState.isDataSaverDenylisted) {
+ if (mDataUsageState != null && mDataUsageState.isDataSaverDenylisted) {
// app is denylisted, launch App Data Usage screen
AppInfoDashboardFragment.startAppInfoFragment(AppDataUsage.class,
R.string.data_usage_app_summary_title,
diff --git a/src/com/android/settings/datausage/WifiDataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/WifiDataUsageSummaryPreferenceController.java
index 9d3054e..4d2dd00 100644
--- a/src/com/android/settings/datausage/WifiDataUsageSummaryPreferenceController.java
+++ b/src/com/android/settings/datausage/WifiDataUsageSummaryPreferenceController.java
@@ -26,23 +26,19 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.net.DataUsageController;
+import java.util.HashSet;
import java.util.Set;
/**
* The controller displays a data usage chart for the specified Wi-Fi network.
*/
public class WifiDataUsageSummaryPreferenceController extends DataUsageSummaryPreferenceController {
- final String mNetworkId;
+ final Set<String> mAllNetworkKeys;
- public WifiDataUsageSummaryPreferenceController(Activity activity,
- Lifecycle lifecycle, PreferenceFragmentCompat fragment, CharSequence networkId) {
+ public WifiDataUsageSummaryPreferenceController(Activity activity, Lifecycle lifecycle,
+ PreferenceFragmentCompat fragment, Set<String> allNetworkKeys) {
super(activity, lifecycle, fragment, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
-
- if (networkId == null) {
- mNetworkId = null;
- } else {
- mNetworkId = String.valueOf(networkId);
- }
+ mAllNetworkKeys = new HashSet<>(allNetworkKeys);
}
@Override
@@ -52,10 +48,11 @@
}
final DataUsageSummaryPreference mPreference = (DataUsageSummaryPreference) preference;
- // TODO(b/126299427): Currently gets data usage of whole Wi-Fi networks, but should get
- // specified one.
final NetworkTemplate template = new NetworkTemplate.Builder(NetworkTemplate.MATCH_WIFI)
- .setWifiNetworkKeys(Set.of(mNetworkId)).build();
+ .setWifiNetworkKeys(mAllNetworkKeys).build();
+ if (mDataUsageController == null) {
+ updateConfiguration(mContext, mSubId, getSubscriptionInfo(mSubId));
+ }
final DataUsageController.DataUsageInfo info = mDataUsageController.getDataUsageInfo(
template);
mDataInfoController.updateDataLimit(info, mPolicyEditor.getPolicy(template));
diff --git a/src/com/android/settings/display/TimeoutListPreference.java b/src/com/android/settings/display/TimeoutListPreference.java
index f9a731d..0b2d18f 100644
--- a/src/com/android/settings/display/TimeoutListPreference.java
+++ b/src/com/android/settings/display/TimeoutListPreference.java
@@ -53,6 +53,7 @@
super.onPrepareDialogBuilder(builder, listener);
if (mAdmin != null) {
builder.setView(R.layout.admin_disabled_other_options_footer);
+ // TODO: replace Text on textview with admin_disabled_other_options
} else {
builder.setView(null);
}
diff --git a/src/com/android/settings/display/darkmode/BedtimeSettings.java b/src/com/android/settings/display/darkmode/BedtimeSettings.java
index d9a458c..28121b2 100644
--- a/src/com/android/settings/display/darkmode/BedtimeSettings.java
+++ b/src/com/android/settings/display/darkmode/BedtimeSettings.java
@@ -17,11 +17,13 @@
package com.android.settings.display.darkmode;
import static android.provider.Settings.ACTION_BEDTIME_SETTINGS;
+import static android.util.FeatureFlagUtils.SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.util.FeatureFlagUtils;
import androidx.annotation.Nullable;
@@ -44,6 +46,10 @@
*/
@Nullable
public Intent getBedtimeSettingsIntent() {
+ if (!FeatureFlagUtils.isEnabled(mContext,
+ SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME)) {
+ return null;
+ }
Intent bedtimeSettingsIntent = new Intent(ACTION_BEDTIME_SETTINGS).setPackage(
mWellbeingPackage);
ResolveInfo bedtimeSettingInfo = mPackageManager.resolveActivity(bedtimeSettingsIntent,
diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
index fe02fda..055e868 100644
--- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
+++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
@@ -16,6 +16,8 @@
package com.android.settings.enterprise;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.DISABLED_BY_IT_ADMIN_TITLE;
+
import android.annotation.NonNull;
import android.annotation.UserIdInt;
import android.app.Activity;
@@ -67,6 +69,13 @@
.createInstance(mActivity, restriction,
new DeviceAdminStringProviderImpl(mActivity),
UserHandle.SYSTEM);
+ DevicePolicyManager devicePolicyManager =
+ mActivity.getSystemService(DevicePolicyManager.class);
+
+ TextView title = mDialogView.findViewById(R.id.admin_support_dialog_title);
+ title.setText(devicePolicyManager.getString(DISABLED_BY_IT_ADMIN_TITLE,
+ () -> mActivity.getString(R.string.disabled_by_policy_title)));
+
}
private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {
diff --git a/src/com/android/settings/enterprise/ApplicationListFragment.java b/src/com/android/settings/enterprise/ApplicationListFragment.java
index 17de9f8..a82789b 100644
--- a/src/com/android/settings/enterprise/ApplicationListFragment.java
+++ b/src/com/android/settings/enterprise/ApplicationListFragment.java
@@ -19,6 +19,7 @@
import android.Manifest;
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.os.Bundle;
import com.android.settings.R;
import com.android.settings.applications.ApplicationFeatureProvider;
@@ -44,6 +45,11 @@
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.app_list_disclosure_settings;
}
diff --git a/src/com/android/settings/enterprise/PrivacySettingsFinancedPreference.java b/src/com/android/settings/enterprise/PrivacySettingsFinancedPreference.java
index 12901a6..8612f6a 100644
--- a/src/com/android/settings/enterprise/PrivacySettingsFinancedPreference.java
+++ b/src/com/android/settings/enterprise/PrivacySettingsFinancedPreference.java
@@ -20,10 +20,8 @@
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;
@@ -61,18 +59,6 @@
*/
@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;
+ return Collections.emptyList();
}
}
diff --git a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
index 931f82a..94415a1 100644
--- a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
@@ -68,16 +68,35 @@
public void onAttach(Context context) {
super.onAttach(context);
final int profileType = getArguments().getInt(ProfileSelectFragment.EXTRA_PROFILE);
- if (profileType == ProfileSelectFragment.ProfileType.WORK) {
- final UserManager userManager = UserManager.get(context);
- final UserHandle workUser = Utils.getManagedProfile(userManager);
- // get work userId
- mUserId = Utils.getManagedProfileId(userManager, UserHandle.myUserId());
- mUserAwareContext = context.createContextAsUser(workUser, 0);
- } else {
- mUserId = UserHandle.myUserId();
- mUserAwareContext = context;
+ final UserManager userManager = context.getSystemService(UserManager.class);
+ final int currentUserId = UserHandle.myUserId();
+ final int newUserId;
+ final Context newUserAwareContext;
+ switch (profileType) {
+ case ProfileSelectFragment.ProfileType.WORK: {
+ final UserHandle workUser;
+ if (currentUserId == UserHandle.MIN_SECONDARY_USER_ID) {
+ newUserId = currentUserId;
+ workUser = UserHandle.of(currentUserId);
+ } else {
+ newUserId = Utils.getManagedProfileId(userManager, currentUserId);
+ workUser = Utils.getManagedProfile(userManager);
+ }
+ newUserAwareContext = context.createContextAsUser(workUser, 0);
+ break;
+ }
+ case ProfileSelectFragment.ProfileType.PERSONAL: {
+ final UserHandle primaryUser = userManager.getPrimaryUser().getUserHandle();
+ newUserId = primaryUser.getIdentifier();
+ newUserAwareContext = context.createContextAsUser(primaryUser, 0);
+ break;
+ }
+ default:
+ newUserId = currentUserId;
+ newUserAwareContext = context;
}
+ mUserId = newUserId;
+ mUserAwareContext = newUserAwareContext;
}
@Override
diff --git a/src/com/android/settings/applications/assist/DefaultVoiceInputPicker.java b/src/com/android/settings/language/DefaultVoiceInputPicker.java
similarity index 85%
rename from src/com/android/settings/applications/assist/DefaultVoiceInputPicker.java
rename to src/com/android/settings/language/DefaultVoiceInputPicker.java
index d4ea4a9..8a73fdf 100644
--- a/src/com/android/settings/applications/assist/DefaultVoiceInputPicker.java
+++ b/src/com/android/settings/language/DefaultVoiceInputPicker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2022 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.applications.assist;
+package com.android.settings.language;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
@@ -31,6 +31,7 @@
import java.util.ArrayList;
import java.util.List;
+/** Controls the Voice Input setting. */
public class DefaultVoiceInputPicker extends DefaultAppPickerFragment {
private VoiceInputHelper mHelper;
@@ -76,7 +77,7 @@
@Override
protected boolean setDefaultKey(String value) {
for (VoiceInputHelper.RecognizerInfo info : mHelper.mAvailableRecognizerInfos) {
- if (TextUtils.equals(value, info.key)) {
+ if (TextUtils.equals(value, info.mKey)) {
Settings.Secure.putString(getContext().getContentResolver(),
Settings.Secure.VOICE_RECOGNITION_SERVICE, value);
return true;
@@ -85,35 +86,38 @@
return true;
}
+ /** Gets the current recognition service component. */
public static ComponentName getCurrentService(VoiceInputHelper helper) {
return helper.mCurrentRecognizer;
}
+ /** Stores the info of the Voice Input provider. */
public static class VoiceInputDefaultAppInfo extends DefaultAppInfo {
public VoiceInputHelper.BaseInfo mInfo;
public VoiceInputDefaultAppInfo(Context context, PackageManager pm, int userId,
VoiceInputHelper.BaseInfo info, boolean enabled) {
- super(context, pm, userId, info.componentName, null /* summary */, enabled);
+ super(context, pm, userId, info.mComponentName, null /* summary */, enabled);
mInfo = info;
}
@Override
public String getKey() {
- return mInfo.key;
+ return mInfo.mKey;
}
@Override
public CharSequence loadLabel() {
- return mInfo.label;
+ return mInfo.mLabel;
}
+ /** Gets the setting intent. */
public Intent getSettingIntent() {
- if (mInfo.settings == null) {
+ if (mInfo.mSettings == null) {
return null;
}
- return new Intent(Intent.ACTION_MAIN).setComponent(mInfo.settings);
+ return new Intent(Intent.ACTION_MAIN).setComponent(mInfo.mSettings);
}
}
}
diff --git a/src/com/android/settings/applications/assist/DefaultVoiceInputPreferenceController.java b/src/com/android/settings/language/DefaultVoiceInputPreferenceController.java
similarity index 94%
rename from src/com/android/settings/applications/assist/DefaultVoiceInputPreferenceController.java
rename to src/com/android/settings/language/DefaultVoiceInputPreferenceController.java
index 59f5731..74c156c 100644
--- a/src/com/android/settings/applications/assist/DefaultVoiceInputPreferenceController.java
+++ b/src/com/android/settings/language/DefaultVoiceInputPreferenceController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2022 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.
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-package com.android.settings.applications.assist;
+package com.android.settings.language;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.net.Uri;
import android.text.TextUtils;
import androidx.preference.Preference;
@@ -33,8 +32,7 @@
import com.android.settingslib.core.lifecycle.events.OnPause;
import com.android.settingslib.core.lifecycle.events.OnResume;
-import java.util.List;
-
+/** Controller of the Voice Input preference. */
public class DefaultVoiceInputPreferenceController extends DefaultAppPreferenceController
implements LifecycleObserver, OnResume, OnPause {
@@ -95,7 +93,7 @@
}
for (VoiceInputHelper.RecognizerInfo info : mHelper.mAvailableRecognizerInfos) {
- if (TextUtils.equals(defaultKey, info.key)) {
+ if (TextUtils.equals(defaultKey, info.mKey)) {
return new DefaultVoiceInputPicker.VoiceInputDefaultAppInfo(mContext,
mPackageManager, mUserId, info, true /* enabled */);
}
diff --git a/src/com/android/settings/language/LanguageAndInputSettings.java b/src/com/android/settings/language/LanguageAndInputSettings.java
index c896629..23e37ba 100644
--- a/src/com/android/settings/language/LanguageAndInputSettings.java
+++ b/src/com/android/settings/language/LanguageAndInputSettings.java
@@ -16,9 +16,12 @@
package com.android.settings.language;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_KEYBOARDS_AND_TOOLS;
+
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -44,8 +47,9 @@
private static final String TAG = "LangAndInputSettings";
private static final String KEY_KEYBOARDS_CATEGORY = "keyboards_category";
+ private static final String KEY_SPEECH_CATEGORY = "speech_category";
private static final String KEY_TEXT_TO_SPEECH = "tts_settings_summary";
- private static final String KEY_POINTER_AND_TTS_CATEGORY = "pointer_and_tts_category";
+ private static final String KEY_POINTER_CATEGORY = "pointer_category";
@Override
public int getMetricsCategory() {
@@ -71,6 +75,14 @@
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ replaceEnterpriseStringTitle("language_and_input_for_work_category",
+ WORK_PROFILE_KEYBOARDS_AND_TOOLS,
+ R.string.language_and_input_for_work_category_title);
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.language_and_input;
}
@@ -98,15 +110,22 @@
Arrays.asList(virtualKeyboardPreferenceController,
physicalKeyboardPreferenceController)));
- // Pointer and Tts
+ // Speech
+ final DefaultVoiceInputPreferenceController defaultVoiceInputPreferenceController =
+ new DefaultVoiceInputPreferenceController(context, lifecycle);
final TtsPreferenceController ttsPreferenceController =
new TtsPreferenceController(context, KEY_TEXT_TO_SPEECH);
+ controllers.add(defaultVoiceInputPreferenceController);
controllers.add(ttsPreferenceController);
+ controllers.add(new PreferenceCategoryController(context,
+ KEY_SPEECH_CATEGORY).setChildren(
+ Arrays.asList(defaultVoiceInputPreferenceController, ttsPreferenceController)));
+
+ // Pointer
final PointerSpeedController pointerController = new PointerSpeedController(context);
controllers.add(pointerController);
controllers.add(new PreferenceCategoryController(context,
- KEY_POINTER_AND_TTS_CATEGORY).setChildren(
- Arrays.asList(pointerController, ttsPreferenceController)));
+ KEY_POINTER_CATEGORY).setChildren(Arrays.asList(pointerController)));
// Input Assistance
controllers.add(new SpellCheckerPreferenceController(context));
diff --git a/src/com/android/settings/applications/assist/VoiceInputHelper.java b/src/com/android/settings/language/VoiceInputHelper.java
similarity index 77%
rename from src/com/android/settings/applications/assist/VoiceInputHelper.java
rename to src/com/android/settings/language/VoiceInputHelper.java
index 285f4f7..7915ba4 100644
--- a/src/com/android/settings/applications/assist/VoiceInputHelper.java
+++ b/src/com/android/settings/language/VoiceInputHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2022 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.applications.assist;
+package com.android.settings.language;
import android.content.ComponentName;
import android.content.Context;
@@ -39,40 +39,46 @@
import java.util.Collections;
import java.util.List;
+/** Helper class of the Voice Input setting. */
public final class VoiceInputHelper {
static final String TAG = "VoiceInputHelper";
final Context mContext;
final List<ResolveInfo> mAvailableRecognition;
- // TODO: Remove this superclass as we only have 1 class now (RecognizerInfo).
- static public class BaseInfo implements Comparable {
- public final ServiceInfo service;
- public final ComponentName componentName;
- public final String key;
- public final ComponentName settings;
- public final CharSequence label;
- public final String labelStr;
- public final CharSequence appLabel;
+ /**
+ * Base info of the Voice Input provider.
+ *
+ * TODO: Remove this superclass as we only have 1 class now (RecognizerInfo).
+ */
+ public static class BaseInfo implements Comparable<BaseInfo> {
+ public final ServiceInfo mService;
+ public final ComponentName mComponentName;
+ public final String mKey;
+ public final ComponentName mSettings;
+ public final CharSequence mLabel;
+ public final String mLabelStr;
+ public final CharSequence mAppLabel;
- public BaseInfo(PackageManager pm, ServiceInfo _service, String _settings) {
- service = _service;
- componentName = new ComponentName(_service.packageName, _service.name);
- key = componentName.flattenToShortString();
- settings = _settings != null
- ? new ComponentName(_service.packageName, _settings) : null;
- label = _service.loadLabel(pm);
- labelStr = label.toString();
- appLabel = _service.applicationInfo.loadLabel(pm);
+ public BaseInfo(PackageManager pm, ServiceInfo service, String settings) {
+ mService = service;
+ mComponentName = new ComponentName(service.packageName, service.name);
+ mKey = mComponentName.flattenToShortString();
+ mSettings = settings != null
+ ? new ComponentName(service.packageName, settings) : null;
+ mLabel = service.loadLabel(pm);
+ mLabelStr = mLabel.toString();
+ mAppLabel = service.applicationInfo.loadLabel(pm);
}
@Override
- public int compareTo(Object another) {
- return labelStr.compareTo(((BaseInfo) another).labelStr);
+ public int compareTo(BaseInfo another) {
+ return mLabelStr.compareTo(another.mLabelStr);
}
}
- static public class RecognizerInfo extends BaseInfo {
+ /** Info of the speech recognizer (i.e. recognition service). */
+ public static class RecognizerInfo extends BaseInfo {
public final boolean mSelectableAsDefault;
public RecognizerInfo(PackageManager pm,
@@ -96,6 +102,7 @@
PackageManager.GET_META_DATA);
}
+ /** Draws the UI of the Voice Input picker page. */
public void buildUi() {
// Get the currently selected recognizer from the secure setting.
String currentSetting = Settings.Secure.getString(
@@ -120,8 +127,8 @@
try (XmlResourceParser parser = si.loadXmlMetaData(mContext.getPackageManager(),
RecognitionService.SERVICE_META_DATA)) {
if (parser == null) {
- throw new XmlPullParserException("No " + RecognitionService.SERVICE_META_DATA +
- " meta-data for " + si.packageName);
+ throw new XmlPullParserException("No " + RecognitionService.SERVICE_META_DATA
+ + " meta-data for " + si.packageName);
}
Resources res = mContext.getPackageManager().getResourcesForApplication(
@@ -132,6 +139,7 @@
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& type != XmlPullParser.START_TAG) {
+ // Intentionally do nothing.
}
String nodeName = parser.getName();
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 8f9787b..ab3ed20 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -16,6 +16,8 @@
package com.android.settings.location;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_LOCATION_SWITCH_TITLE;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.location.SettingInjectorService;
@@ -63,6 +65,7 @@
private LocationSwitchBarController mSwitchBarController;
private LocationEnabler mLocationEnabler;
+ private RecentLocationAccessPreferenceController mController;
@Override
public int getMetricsCategory() {
@@ -86,18 +89,35 @@
super.onAttach(context);
use(AppLocationPermissionPreferenceController.class).init(this);
- use(RecentLocationAccessPreferenceController.class).init(this);
+ mController = use(RecentLocationAccessPreferenceController.class);
+ mController.init(this);
use(RecentLocationAccessSeeAllButtonPreferenceController.class).init(this);
use(LocationForWorkPreferenceController.class).init(this);
use(LocationSettingsFooterPreferenceController.class).init(this);
}
@Override
+ public void onPause() {
+ super.onPause();
+ if (mController != null) {
+ mController.clearPreferenceList();
+ }
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.location_settings;
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ replaceEnterpriseStringTitle("managed_profile_location_switch",
+ WORK_PROFILE_LOCATION_SWITCH_TITLE, R.string.managed_profile_location_switch_title);
+ }
+
+ @Override
protected String getLogTag() {
return TAG;
}
diff --git a/src/com/android/settings/location/LocationWorkProfileSettings.java b/src/com/android/settings/location/LocationWorkProfileSettings.java
index 24c44f3..d8db33d 100644
--- a/src/com/android/settings/location/LocationWorkProfileSettings.java
+++ b/src/com/android/settings/location/LocationWorkProfileSettings.java
@@ -16,8 +16,11 @@
package com.android.settings.location;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_LOCATION_SWITCH_TITLE;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.os.Bundle;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -41,6 +44,13 @@
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ replaceEnterpriseStringTitle("managed_profile_location_switch",
+ WORK_PROFILE_LOCATION_SWITCH_TITLE, R.string.managed_profile_location_switch_title);
+ }
+
+ @Override
protected String getLogTag() {
return TAG;
}
diff --git a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
index ba660ee..ea3704c 100644
--- a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
@@ -127,6 +127,15 @@
}
/**
+ * Clears the list of apps which recently accessed location from the screen.
+ */
+ public void clearPreferenceList() {
+ if (mCategoryRecentLocationRequests != null) {
+ mCategoryRecentLocationRequests.removeAll();
+ }
+ }
+
+ /**
* Initialize {@link ProfileSelectFragment.ProfileType} of the controller
*
* @param type {@link ProfileSelectFragment.ProfileType} of the controller.
diff --git a/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java b/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java
index 9524164..c6d1ea0 100644
--- a/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java
+++ b/src/com/android/settings/network/SwitchToEuiccSubscriptionSidecar.java
@@ -69,20 +69,15 @@
}
}
- /** Starts calling EuiccManager#switchToSubscription to enable/disable the eSIM profile. */
- // ToDo: delete this api and refactor the related code.
- public void run(int subscriptionId) {
- setState(State.RUNNING, Substate.UNUSED);
- mCallbackIntent = createCallbackIntent();
- mEuiccManager.switchToSubscription(subscriptionId, mCallbackIntent);
- }
-
/**
* Starts calling EuiccManager#switchToSubscription to enable/disable the eSIM profile.
*
* @param subscriptionId the esim's subscriptionId.
- * @param port the esim's portId. If user wants to inactivate esim, then user must to assign the
- * the port. If user wants to activate esim, then the port can be -1.
+ * @param port the esim's portId. If user wants to inactivate esim, then user must to assign
+ * the corresponding port. If user wants to activate esim, then the port can be
+ * {@link UiccSlotUtil#INVALID_PORT_ID}. When it is
+ * {@link UiccSlotUtil#INVALID_PORT_ID}, the system will reassign a corresponding
+ * port id.
* @param removedSubInfo if the all of slots have sims, it should remove the one of active sim.
* If the removedSubInfo is null, then use the default value.
* The default value is the esim slot and portId 0.
diff --git a/src/com/android/settings/network/SwitchToRemovableSlotSidecar.java b/src/com/android/settings/network/SwitchToRemovableSlotSidecar.java
index 9b9c0dd..e98b405 100644
--- a/src/com/android/settings/network/SwitchToRemovableSlotSidecar.java
+++ b/src/com/android/settings/network/SwitchToRemovableSlotSidecar.java
@@ -81,29 +81,6 @@
}
/**
- * Starts switching to the removable slot. It disables the active eSIM profile before switching
- * if there is one.
- *
- * @param physicalSlotId removable physical SIM slot ID.
- */
- // ToDo: delete this api and refactor the related code.
- public void run(int physicalSlotId) {
- mPhysicalSlotId = physicalSlotId;
- SubscriptionManager subscriptionManager =
- getContext().getSystemService(SubscriptionManager.class);
- if (SubscriptionUtil.getActiveSubscriptions(subscriptionManager).stream()
- .anyMatch(SubscriptionInfo::isEmbedded)) {
- // In SS mode, the esim is active, then inactivate the esim.
- Log.i(TAG, "There is an active eSIM profile. Disable the profile first.");
- // Use INVALID_SUBSCRIPTION_ID to disable the only active profile.
- mSwitchToSubscriptionSidecar.run(SubscriptionManager.INVALID_SUBSCRIPTION_ID, 0, null);
- } else {
- Log.i(TAG, "There is no active eSIM profiles. Start to switch to removable slot.");
- mSwitchSlotSidecar.runSwitchToRemovableSlot(mPhysicalSlotId, null);
- }
- }
-
- /**
* Starts switching to the removable slot.
*
* @param physicalSlotId removable physical SIM slot ID.
diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java
index 5f78acc..f888ea7 100644
--- a/src/com/android/settings/notification/ConfigureNotificationSettings.java
+++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java
@@ -16,6 +16,9 @@
package com.android.settings.notification;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_LOCK_SCREEN_REDACT_NOTIFICATION_SUMMARY;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_LOCK_SCREEN_REDACT_NOTIFICATION_TITLE;
+
import android.app.Activity;
import android.app.Application;
import android.app.settings.SettingsEnums;
@@ -70,6 +73,17 @@
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ replaceEnterpriseStringTitle("lock_screen_work_redact",
+ WORK_PROFILE_LOCK_SCREEN_REDACT_NOTIFICATION_TITLE,
+ R.string.lock_screen_notifs_redact_work);
+ replaceEnterpriseStringSummary("lock_screen_work_redact",
+ WORK_PROFILE_LOCK_SCREEN_REDACT_NOTIFICATION_SUMMARY,
+ R.string.lock_screen_notifs_redact_work_summary);
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.configure_notification_settings;
}
diff --git a/src/com/android/settings/notification/OWNERS b/src/com/android/settings/notification/OWNERS
index edf266e..a2ae9ce 100644
--- a/src/com/android/settings/notification/OWNERS
+++ b/src/com/android/settings/notification/OWNERS
@@ -1,4 +1,5 @@
# Default reviewers for this and subdirectories.
-asc@google.com
+beverlyt@google.com
dsandler@android.com
-juliacr@google.com
\ No newline at end of file
+juliacr@google.com
+yurilin@google.com
\ No newline at end of file
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index ab53a3f..971937c 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -16,6 +16,8 @@
package com.android.settings.notification;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SOUND_SETTINGS_SECTION_HEADER;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
@@ -97,6 +99,9 @@
.findFragmentByTag(TAG);
mDialogFragment = dialogFragment;
}
+ replaceEnterpriseStringTitle("sound_work_settings",
+ WORK_PROFILE_SOUND_SETTINGS_SECTION_HEADER,
+ R.string.sound_work_settings);
}
@Override
diff --git a/src/com/android/settings/notification/SoundWorkSettings.java b/src/com/android/settings/notification/SoundWorkSettings.java
index d30c04f..eb7f05e 100644
--- a/src/com/android/settings/notification/SoundWorkSettings.java
+++ b/src/com/android/settings/notification/SoundWorkSettings.java
@@ -16,6 +16,12 @@
package com.android.settings.notification;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_ALARM_RINGTONE_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_NOTIFICATION_RINGTONE_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_RINGTONE_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_USE_PERSONAL_SOUNDS_SUMMARY;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_USE_PERSONAL_SOUNDS_TITLE;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
@@ -64,6 +70,18 @@
mRequestPreference = findPreference(selectedPreference);
}
}
+ replaceEnterpriseStringTitle("work_use_personal_sounds",
+ WORK_PROFILE_USE_PERSONAL_SOUNDS_TITLE, R.string.work_use_personal_sounds_title);
+ replaceEnterpriseStringSummary("work_use_personal_sounds",
+ WORK_PROFILE_USE_PERSONAL_SOUNDS_SUMMARY,
+ R.string.work_use_personal_sounds_summary);
+ replaceEnterpriseStringTitle("work_ringtone",
+ WORK_PROFILE_RINGTONE_TITLE, R.string.work_ringtone_title);
+ replaceEnterpriseStringTitle("work_alarm_ringtone",
+ WORK_PROFILE_ALARM_RINGTONE_TITLE, R.string.work_alarm_ringtone_title);
+ replaceEnterpriseStringTitle("work_notification",
+ WORK_PROFILE_NOTIFICATION_RINGTONE_TITLE,
+ R.string.work_notification_ringtone_title);
}
@Override
diff --git a/src/com/android/settings/password/ForgotPasswordActivity.java b/src/com/android/settings/password/ForgotPasswordActivity.java
index 1f1df18..d963a05 100644
--- a/src/com/android/settings/password/ForgotPasswordActivity.java
+++ b/src/com/android/settings/password/ForgotPasswordActivity.java
@@ -16,12 +16,16 @@
package com.android.settings.password;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.FORGOT_PASSWORD_TEXT;
+
import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
+import android.widget.TextView;
import com.android.settings.R;
@@ -45,6 +49,11 @@
}
setContentView(R.layout.forgot_password_activity);
+ DevicePolicyManager devicePolicyManager = getSystemService(DevicePolicyManager.class);
+ TextView forgotPasswordText = (TextView) findViewById(R.id.forgot_password_text);
+ forgotPasswordText.setText(devicePolicyManager.getString(
+ FORGOT_PASSWORD_TEXT, () -> getString(R.string.forgot_password_text)));
+
final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
layout.getMixin(FooterBarMixin.class).setPrimaryButton(
new FooterButton.Builder(this)
diff --git a/src/com/android/settings/privacy/PrivacyDashboardFragment.java b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
index 7aa65b7..0638c60 100644
--- a/src/com/android/settings/privacy/PrivacyDashboardFragment.java
+++ b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
@@ -16,8 +16,15 @@
package com.android.settings.privacy;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECTED_WORK_AND_PERSONAL_APPS_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_LOCKED_NOTIFICATION_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_NOTIFICATIONS_SECTION_HEADER;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_PRIVACY_POLICY_INFO;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_PRIVACY_POLICY_INFO_SUMMARY;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.os.Bundle;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -51,6 +58,24 @@
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ replaceEnterpriseStringTitle("privacy_lock_screen_work_profile_notifications",
+ WORK_PROFILE_LOCKED_NOTIFICATION_TITLE,
+ R.string.locked_work_profile_notification_title);
+ replaceEnterpriseStringTitle("interact_across_profiles_privacy",
+ CONNECTED_WORK_AND_PERSONAL_APPS_TITLE, R.string.interact_across_profiles_title);
+ replaceEnterpriseStringTitle("privacy_work_profile_notifications_category",
+ WORK_PROFILE_NOTIFICATIONS_SECTION_HEADER, R.string.profile_section_header);
+ replaceEnterpriseStringTitle("work_policy_info",
+ WORK_PROFILE_PRIVACY_POLICY_INFO, R.string.work_policy_privacy_settings);
+ replaceEnterpriseStringSummary("work_policy_info",
+ WORK_PROFILE_PRIVACY_POLICY_INFO_SUMMARY,
+ R.string.work_policy_privacy_settings_summary);
+
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.privacy_dashboard_settings;
}
diff --git a/src/com/android/settings/security/LockscreenDashboardFragment.java b/src/com/android/settings/security/LockscreenDashboardFragment.java
index 39355f3..b3351ac 100644
--- a/src/com/android/settings/security/LockscreenDashboardFragment.java
+++ b/src/com/android/settings/security/LockscreenDashboardFragment.java
@@ -16,9 +16,13 @@
package com.android.settings.security;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_LOCKED_NOTIFICATION_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_NOTIFICATIONS_SECTION_HEADER;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.hardware.display.AmbientDisplayConfiguration;
+import android.os.Bundle;
import androidx.annotation.VisibleForTesting;
@@ -76,6 +80,16 @@
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ replaceEnterpriseStringTitle("security_setting_lock_screen_notif_work",
+ WORK_PROFILE_LOCKED_NOTIFICATION_TITLE,
+ R.string.locked_work_profile_notification_title);
+ replaceEnterpriseStringTitle("security_setting_lock_screen_notif_work_header",
+ WORK_PROFILE_NOTIFICATIONS_SECTION_HEADER, R.string.profile_section_header);
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.security_lockscreen_settings;
}
diff --git a/src/com/android/settings/security/SecurityAdvancedSettings.java b/src/com/android/settings/security/SecurityAdvancedSettings.java
index ce4a59c..e5f4945 100644
--- a/src/com/android/settings/security/SecurityAdvancedSettings.java
+++ b/src/com/android/settings/security/SecurityAdvancedSettings.java
@@ -16,9 +16,17 @@
package com.android.settings.security;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.FINGERPRINT_FOR_WORK;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGED_DEVICE_INFO;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGE_DEVICE_ADMIN_APPS;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SECURITY_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SET_UNLOCK_LAUNCH_PICKER_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_UNIFY_LOCKS_SUMMARY;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
+import android.os.Bundle;
import com.android.settings.R;
import com.android.settings.biometrics.combination.CombinedBiometricProfileStatusPreferenceController;
@@ -54,6 +62,27 @@
"com.android.settings.category.ia.legacy_advanced_security";
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ replaceEnterpriseStringTitle("unlock_set_or_change_profile",
+ WORK_PROFILE_SET_UNLOCK_LAUNCH_PICKER_TITLE,
+ R.string.unlock_set_unlock_launch_picker_title_profile);
+ replaceEnterpriseStringSummary("unification",
+ WORK_PROFILE_UNIFY_LOCKS_SUMMARY,
+ R.string.lock_settings_profile_unification_summary);
+ replaceEnterpriseStringTitle("fingerprint_settings_profile",
+ FINGERPRINT_FOR_WORK,
+ R.string.security_settings_work_fingerprint_preference_title);
+ replaceEnterpriseStringTitle("manage_device_admin",
+ MANAGE_DEVICE_ADMIN_APPS, R.string.manage_device_admin);
+ replaceEnterpriseStringTitle("security_category_profile",
+ WORK_PROFILE_SECURITY_TITLE, R.string.lock_settings_profile_title);
+ replaceEnterpriseStringTitle("enterprise_privacy", MANAGED_DEVICE_INFO,
+ R.string.enterprise_privacy_settings);
+
+ }
+
+ @Override
public int getMetricsCategory() {
return SettingsEnums.SECURITY_ADVANCED;
}
diff --git a/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java b/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
index 2f8d58d..49f94c8 100644
--- a/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
@@ -32,14 +32,12 @@
private static final int MY_USER_ID = UserHandle.myUserId();
private final LockPatternUtils mLockPatternUtils;
- private TrustAgentManager mTrustAgentManager;
public ManageTrustAgentsPreferenceController(Context context, String key) {
super(context, key);
final SecurityFeatureProvider securityFeatureProvider = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider();
mLockPatternUtils = securityFeatureProvider.getLockPatternUtils(context);
- mTrustAgentManager = securityFeatureProvider.getTrustAgentManager();
}
@Override
@@ -66,6 +64,6 @@
}
private int getTrustAgentCount() {
- return mTrustAgentManager.getActiveTrustAgents(mContext, mLockPatternUtils).size();
+ return mLockPatternUtils.getEnabledTrustAgents(MY_USER_ID).size();
}
}
diff --git a/src/com/android/settings/sim/ChooseSimActivity.java b/src/com/android/settings/sim/ChooseSimActivity.java
index d0ccc4c..cebc1ba 100644
--- a/src/com/android/settings/sim/ChooseSimActivity.java
+++ b/src/com/android/settings/sim/ChooseSimActivity.java
@@ -159,11 +159,12 @@
mSelectedItemIndex = subItem.getId();
if (mSelectedItemIndex == INDEX_PSIM) {
Log.i(TAG, "Ready to switch to pSIM slot.");
- mSwitchToRemovableSlotSidecar.run(UiccSlotUtil.INVALID_PHYSICAL_SLOT_ID);
+ mSwitchToRemovableSlotSidecar.run(UiccSlotUtil.INVALID_PHYSICAL_SLOT_ID, null);
} else {
Log.i(TAG, "Ready to switch to eSIM subscription with index: " + mSelectedItemIndex);
mSwitchToEuiccSubscriptionSidecar.run(
- mEmbeddedSubscriptions.get(mSelectedItemIndex).getSubscriptionId());
+ mEmbeddedSubscriptions.get(mSelectedItemIndex).getSubscriptionId(),
+ UiccSlotUtil.INVALID_PORT_ID, null);
}
}
diff --git a/src/com/android/settings/sim/SwitchToEsimConfirmDialogActivity.java b/src/com/android/settings/sim/SwitchToEsimConfirmDialogActivity.java
index be2fa2d..db6e1b4 100644
--- a/src/com/android/settings/sim/SwitchToEsimConfirmDialogActivity.java
+++ b/src/com/android/settings/sim/SwitchToEsimConfirmDialogActivity.java
@@ -23,6 +23,7 @@
import com.android.settings.R;
import com.android.settings.SidecarFragment;
import com.android.settings.network.SwitchToEuiccSubscriptionSidecar;
+import com.android.settings.network.UiccSlotUtil;
import com.android.settings.network.telephony.AlertDialogFragment;
import com.android.settings.network.telephony.ConfirmDialogFragment;
import com.android.settings.network.telephony.SubscriptionActionDialogActivity;
@@ -110,7 +111,8 @@
return;
}
Log.i(TAG, "User confirmed to switch to embedded slot.");
- mSwitchToEuiccSubscriptionSidecar.run(mSubToEnabled.getSubscriptionId());
+ mSwitchToEuiccSubscriptionSidecar.run(mSubToEnabled.getSubscriptionId(),
+ UiccSlotUtil.INVALID_PORT_ID, null);
showProgressDialog(
getString(
R.string.sim_action_switch_sub_dialog_progress,
diff --git a/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java b/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java
index e0bc9cd..61241d0 100644
--- a/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java
+++ b/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java
@@ -26,12 +26,14 @@
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.telephony.UiccCardInfo;
import android.telephony.UiccSlotInfo;
import android.util.Log;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.UiccSlotUtil;
import com.android.settings.network.UiccSlotsException;
+import com.android.settings.network.telephony.ToggleSubscriptionDialogActivity;
import com.android.settings.sim.ChooseSimActivity;
import com.android.settings.sim.DsdsDialogActivity;
import com.android.settings.sim.SimActivationNotifier;
@@ -40,6 +42,7 @@
import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -83,8 +86,8 @@
throw new IllegalStateException("Cannot be called from main thread.");
}
- if (mTelMgr.getActiveModemCount() > 1) {
- Log.i(TAG, "The device is already in DSDS mode. Do nothing.");
+ if (mTelMgr.getActiveModemCount() > 1 && !isMultipleEnabledProfilesSupported()) {
+ Log.i(TAG, "The device is already in DSDS mode and no MEP. Do nothing.");
return;
}
@@ -96,17 +99,30 @@
int lastRemovableSlotState = getLastRemovableSimSlotState(mContext);
int currentRemovableSlotState = removableSlotInfo.getCardStateInfo();
+ boolean isRemovableSimInserted =
+ lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT
+ && currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT;
+ boolean isRemovableSimRemoved =
+ lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT
+ && currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT;
// Sets the current removable slot state.
setRemovableSimSlotState(mContext, currentRemovableSlotState);
- if (lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT
- && currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT) {
+ if (mTelMgr.getActiveModemCount() > 1 && isMultipleEnabledProfilesSupported()) {
+ if(!isRemovableSimInserted) {
+ Log.i(TAG, "Removable Sim is not inserted in DSDS mode and MEP. Do nothing.");
+ return;
+ }
+ handleRemovableSimInsertUnderDsdsMep(removableSlotInfo);
+ return;
+ }
+
+ if (isRemovableSimInserted) {
handleSimInsert(removableSlotInfo);
return;
}
- if (lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT
- && currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT) {
+ if (isRemovableSimRemoved) {
handleSimRemove(removableSlotInfo);
return;
}
@@ -210,10 +226,11 @@
}
List<SubscriptionInfo> groupedEmbeddedSubscriptions = getGroupedEmbeddedSubscriptions();
-
if (groupedEmbeddedSubscriptions.size() == 0 || !removableSlotInfo.getPorts().stream()
.findFirst().get().isActive()) {
- Log.i(TAG, "eSIM slot is active or no subscriptions exist. Do nothing.");
+ Log.i(TAG, "eSIM slot is active or no subscriptions exist. Do nothing."
+ + " The removableSlotInfo: " + removableSlotInfo
+ + ", groupedEmbeddedSubscriptions: " + groupedEmbeddedSubscriptions);
return;
}
@@ -231,6 +248,23 @@
startChooseSimActivity(false);
}
+ private void handleRemovableSimInsertUnderDsdsMep(UiccSlotInfo removableSlotInfo) {
+ Log.i(TAG, "Handle Removable SIM inserted under DSDS+Mep.");
+
+ if (removableSlotInfo.getPorts().stream().findFirst().get().isActive()) {
+ Log.i(TAG, "The removable slot is already active. Do nothing. removableSlotInfo: "
+ + removableSlotInfo);
+ return;
+ }
+
+ List<SubscriptionInfo> subscriptionInfos = getAvailableRemovableSubscription();
+ if (subscriptionInfos == null && subscriptionInfos.get(0) != null) {
+ Log.e(TAG, "Unable to find the removable subscriptionInfo. Do nothing.");
+ return;
+ }
+ startSimConfirmDialogActivity(subscriptionInfos.get(0).getSubscriptionId());
+ }
+
private int getLastRemovableSimSlotState(Context context) {
final SharedPreferences prefs = context.getSharedPreferences(EUICC_PREFS, MODE_PRIVATE);
return prefs.getInt(KEY_REMOVABLE_SLOT_STATE, UiccSlotInfo.CARD_STATE_INFO_ABSENT);
@@ -260,7 +294,6 @@
}
for (UiccSlotInfo slotInfo : slotInfos) {
if (slotInfo != null && slotInfo.isRemovable()) {
-
return slotInfo;
}
}
@@ -296,6 +329,16 @@
.collect(Collectors.toList()));
}
+ protected List<SubscriptionInfo> getAvailableRemovableSubscription() {
+ List<SubscriptionInfo> subList = new ArrayList<>();
+ for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mContext)) {
+ if (!info.isEmbedded()) {
+ subList.add(info);
+ }
+ }
+ return subList;
+ }
+
private void startChooseSimActivity(boolean psimInserted) {
Intent intent = ChooseSimActivity.getIntent(mContext);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -316,5 +359,25 @@
mContext.startActivity(intent);
}
+ private void startSimConfirmDialogActivity(int subId) {
+ if (!SubscriptionManager.isUsableSubscriptionId(subId)) {
+ Log.i(TAG, "Unable to enable subscription due to invalid subscription ID.");
+ return;
+ }
+ Intent intent = ToggleSubscriptionDialogActivity.getIntent(mContext, subId, true);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(intent);
+ }
+
+ private boolean isMultipleEnabledProfilesSupported() {
+ List<UiccCardInfo> cardInfos = mTelMgr.getUiccCardsInfo();
+ if (cardInfos == null) {
+ Log.w(TAG, "UICC cards info list is empty.");
+ return false;
+ }
+ return cardInfos.stream().anyMatch(
+ cardInfo -> cardInfo.isMultipleEnabledProfilesSupported());
+ }
+
private SimSlotChangeHandler() {}
}
diff --git a/src/com/android/settings/users/UserDialogs.java b/src/com/android/settings/users/UserDialogs.java
index 3c19d7e..4dcec4d 100644
--- a/src/com/android/settings/users/UserDialogs.java
+++ b/src/com/android/settings/users/UserDialogs.java
@@ -18,6 +18,7 @@
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_REMOVE_MESSAGE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_REMOVE_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_MANAGED_BY;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
@@ -89,6 +90,8 @@
*/
private static View createRemoveManagedUserDialogView(Context context, int userId) {
PackageManager packageManager = context.getPackageManager();
+ DevicePolicyManager devicePolicyManager =
+ context.getSystemService(DevicePolicyManager.class);
ApplicationInfo mdmApplicationInfo = Utils.getAdminApplicationInfo(context, userId);
if (mdmApplicationInfo == null) {
return null;
@@ -102,6 +105,16 @@
Drawable badgedApplicationIcon = packageManager.getApplicationIcon(mdmApplicationInfo);
imageView.setImageDrawable(badgedApplicationIcon);
+ TextView openingParagraph = (TextView)
+ view.findViewById(R.id.delete_managed_profile_opening_paragraph);
+ openingParagraph.setText(devicePolicyManager.getString(WORK_PROFILE_MANAGED_BY,
+ () -> context.getString(
+ R.string.opening_paragraph_delete_profile_unknown_company)));
+ TextView closingParagraph = (TextView)
+ view.findViewById(R.id.delete_managed_profile_closing_paragraph);
+ closingParagraph.setText(devicePolicyManager.getString(WORK_PROFILE_CONFIRM_REMOVE_MESSAGE,
+ () -> context.getString(R.string.work_profile_confirm_remove_message)));
+
CharSequence appLabel = packageManager.getApplicationLabel(mdmApplicationInfo);
CharSequence badgedAppLabel = packageManager.getUserBadgedLabel(appLabel,
new UserHandle(userId));
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index f9d0db0..e3181e3 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -435,9 +435,9 @@
mDataUsageSummaryPref = screen.findPreference(KEY_DATA_USAGE_HEADER);
mDataUsageSummaryPref.setVisible(true);
mSummaryHeaderController =
- new WifiDataUsageSummaryPreferenceController(mFragment.getActivity(),
- mLifecycle, (PreferenceFragmentCompat) mFragment,
- mWifiEntry.getTitle());
+ new WifiDataUsageSummaryPreferenceController(mFragment.getActivity(),
+ mLifecycle, (PreferenceFragmentCompat) mFragment,
+ mWifiEntry.getWifiConfiguration().getAllNetworkKeys());
return;
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorialTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorialTest.java
index cf0ce96..6efdcf7a 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorialTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorialTest.java
@@ -22,26 +22,41 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.verify;
+
import android.content.Context;
+import android.content.DialogInterface;
import androidx.appcompat.app.AlertDialog;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Tests for {@link AccessibilityGestureNavigationTutorial}. */
@RunWith(RobolectricTestRunner.class)
public final class AccessibilityGestureNavigationTutorialTest {
- private Context mContext;
+ @Rule
+ public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+
+ @Mock
+ private DialogInterface.OnClickListener mMockOnClickListener;
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
private int mShortcutTypes;
@Before
public void setUp() {
- mContext = RuntimeEnvironment.application;
+ mContext.setTheme(R.style.Theme_AppCompat);
mShortcutTypes = /* initial */ 0;
}
@@ -86,4 +101,28 @@
mShortcutTypes)).hasSize(/* expectedSize= */ 2);
assertThat(alertDialog).isNotNull();
}
+
+ @Test
+ public void performClickOnNegativeButton_turnOnSoftwareShortcut_dismiss() {
+ mShortcutTypes |= UserShortcutType.SOFTWARE;
+ final AlertDialog alertDialog =
+ createAccessibilityTutorialDialog(mContext, mShortcutTypes);
+ alertDialog.show();
+
+ alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
+
+ assertThat(alertDialog.isShowing()).isFalse();
+ }
+
+ @Test
+ public void performClickOnNegativeButton_turnOnSoftwareShortcut_callOnClickListener() {
+ mShortcutTypes |= UserShortcutType.SOFTWARE;
+ final AlertDialog alertDialog =
+ createAccessibilityTutorialDialog(mContext, mShortcutTypes, mMockOnClickListener);
+ alertDialog.show();
+
+ alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
+
+ verify(mMockOnClickListener).onClick(alertDialog, DialogInterface.BUTTON_NEGATIVE);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java
index 06a046b..ea0f317 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java
@@ -40,6 +40,7 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
@@ -53,6 +54,7 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadow.api.Shadow;
@@ -92,6 +94,7 @@
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
when(mFragment.getContext()).thenReturn(mContext);
+ when(mFragment.getActivity()).thenReturn(Robolectric.setupActivity(FragmentActivity.class));
mScreen = spy(new PreferenceScreen(mContext, null));
when(mScreen.getPreferenceManager()).thenReturn(mPreferenceManager);
doReturn(mScreen).when(mFragment).getPreferenceScreen();
diff --git a/tests/robotests/src/com/android/settings/accessibility/AudioDescriptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AudioDescriptionPreferenceControllerTest.java
new file mode 100644
index 0000000..1d3ffa8
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/AudioDescriptionPreferenceControllerTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2022 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 static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+
+@RunWith(RobolectricTestRunner.class)
+public class AudioDescriptionPreferenceControllerTest {
+
+ private static final String KEY_AUDIO_DESCRIPTION =
+ Settings.Secure.ENABLED_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT;
+ private static final int UNKNOWN = -1;
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ private final SwitchPreference mSwitchPreference = spy(new SwitchPreference(mContext));
+ private final AudioDescriptionPreferenceController mController =
+ new AudioDescriptionPreferenceController(mContext,
+ AudioDescriptionPreferenceController.PREF_KEY);
+
+ @Before
+ public void setUp() {
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
+ mSwitchPreference.setKey(AudioDescriptionPreferenceController.PREF_KEY);
+ screen.addPreference(mSwitchPreference);
+ mController.displayPreference(screen);
+ }
+
+ @Test
+ public void getAvailabilityStatus_byDefault_shouldReturnAvailable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ public void isChecked_disableAudioDescription_onResumeShouldReturnFalse() {
+ Settings.Secure.putInt(mContext.getContentResolver(), KEY_AUDIO_DESCRIPTION, OFF);
+
+ mController.updateState(mSwitchPreference);
+
+ assertThat(mController.isChecked()).isFalse();
+ assertThat(mSwitchPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isChecked_enableAudioDescription_onResumeShouldReturnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(), KEY_AUDIO_DESCRIPTION, ON);
+
+ mController.updateState(mSwitchPreference);
+
+ assertThat(mController.isChecked()).isTrue();
+ assertThat(mSwitchPreference.isChecked()).isTrue();
+ }
+
+ @Test
+ public void performClick_enableAudioDescription_shouldReturnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(), KEY_AUDIO_DESCRIPTION, OFF);
+
+ mController.updateState(mSwitchPreference);
+
+ mSwitchPreference.performClick();
+
+ verify(mSwitchPreference).setChecked(true);
+ assertThat(mController.isChecked()).isTrue();
+ assertThat(mSwitchPreference.isChecked()).isTrue();
+ }
+
+ @Test
+ public void performClick_disableAudioDescription_shouldReturnFalse() {
+ Settings.Secure.putInt(mContext.getContentResolver(), KEY_AUDIO_DESCRIPTION, ON);
+
+ mController.updateState(mSwitchPreference);
+
+ mSwitchPreference.performClick();
+
+ verify(mSwitchPreference).setChecked(false);
+ assertThat(mController.isChecked()).isFalse();
+ assertThat(mSwitchPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void setChecked_setFalse_shouldDisableAudioDescription() {
+ mController.setChecked(false);
+
+ assertThat(Settings.Secure.getInt(
+ mContext.getContentResolver(), KEY_AUDIO_DESCRIPTION, UNKNOWN)).isEqualTo(OFF);
+ }
+
+ @Test
+ public void setChecked_setTrue_shouldEnableAudioDescription() {
+ mController.setChecked(true);
+
+ assertThat(Settings.Secure.getInt(
+ mContext.getContentResolver(), KEY_AUDIO_DESCRIPTION, UNKNOWN)).isEqualTo(ON);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragmentTest.java
new file mode 100644
index 0000000..c44352f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragmentTest.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2022 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 static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+import android.service.quicksettings.TileService;
+
+import androidx.preference.PreferenceManager;
+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.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowPackageManager;
+
+import java.util.Arrays;
+
+/** Tests for {@link LaunchAccessibilityActivityPreferenceFragment} */
+@RunWith(RobolectricTestRunner.class)
+public class LaunchAccessibilityActivityPreferenceFragmentTest {
+
+ private static final String PLACEHOLDER_PACKAGE_NAME = "com.placeholder.example";
+ private static final String PLACEHOLDER_TILE_CLASS_NAME =
+ PLACEHOLDER_PACKAGE_NAME + "tile.placeholder";
+ private static final String PLACEHOLDER_TILE_CLASS_NAME2 =
+ PLACEHOLDER_PACKAGE_NAME + "tile.placeholder2";
+ private static final ComponentName PLACEHOLDER_TILE_COMPONENT_NAME = new ComponentName(
+ PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME);
+ private static final String PLACEHOLDER_TILE_NAME =
+ PLACEHOLDER_PACKAGE_NAME + "tile.placeholder";
+ private static final String PLACEHOLDER_TILE_NAME2 =
+ PLACEHOLDER_PACKAGE_NAME + "tile.placeholder2";
+
+ private TestLaunchAccessibilityActivityPreferenceFragment mFragment;
+ private PreferenceScreen mScreen;
+ private Context mContext = ApplicationProvider.getApplicationContext();
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private PreferenceManager mPreferenceManager;
+
+ @Before
+ public void setUpTestFragment() {
+ MockitoAnnotations.initMocks(this);
+
+ mFragment = spy(new TestLaunchAccessibilityActivityPreferenceFragment());
+ when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
+ when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
+ when(mFragment.getContext()).thenReturn(mContext);
+ mScreen = spy(new PreferenceScreen(mContext, /* attrs= */ null));
+ when(mScreen.getPreferenceManager()).thenReturn(mPreferenceManager);
+ doReturn(mScreen).when(mFragment).getPreferenceScreen();
+ }
+
+ @Test
+ public void getTileName_noTileServiceAssigned_returnNull() {
+ assertThat(mFragment.getTileName()).isNull();
+ }
+
+ @Test
+ public void getTileName_hasOneTileService_haveMatchString() {
+ final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE);
+ final ResolveInfo info = new ResolveInfo();
+ info.serviceInfo = new FakeServiceInfo();
+ info.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
+ info.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME;
+ final ShadowPackageManager shadowPackageManager =
+ Shadows.shadowOf(mContext.getPackageManager());
+ shadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info));
+
+ final CharSequence tileName = mFragment.getTileName();
+ assertThat(tileName.toString()).isEqualTo(PLACEHOLDER_TILE_NAME);
+ }
+
+ @Test
+ public void getTileName_hasTwoTileServices_haveMatchString() {
+ final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE);
+ final ResolveInfo info = new ResolveInfo();
+ info.serviceInfo = new FakeServiceInfo();
+ info.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
+ info.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME;
+ final ResolveInfo info2 = new ResolveInfo();
+ info2.serviceInfo = new FakeServiceInfo2();
+ info2.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
+ info2.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME2;
+ final ShadowPackageManager shadowPackageManager =
+ Shadows.shadowOf(mContext.getPackageManager());
+ shadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info, info2));
+
+ final CharSequence tileName = mFragment.getTileName();
+ assertThat(tileName.toString()).isEqualTo(PLACEHOLDER_TILE_NAME);
+ }
+
+ private static class FakeServiceInfo extends ServiceInfo {
+ public String loadLabel(PackageManager mgr) {
+ return PLACEHOLDER_TILE_NAME;
+ }
+ }
+
+ private static class FakeServiceInfo2 extends ServiceInfo {
+ public String loadLabel(PackageManager mgr) {
+ return PLACEHOLDER_TILE_NAME2;
+ }
+ }
+
+ private static class TestLaunchAccessibilityActivityPreferenceFragment
+ extends LaunchAccessibilityActivityPreferenceFragment {
+
+ @Override
+ protected ComponentName getTileComponentName() {
+ return PLACEHOLDER_TILE_COMPONENT_NAME;
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java
new file mode 100644
index 0000000..236f9f2
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragmentTest.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2022 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 static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+import android.service.quicksettings.TileService;
+
+import androidx.preference.PreferenceManager;
+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.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowPackageManager;
+
+import java.util.Arrays;
+
+/** Tests for {@link ToggleAccessibilityServicePreferenceFragment} */
+@RunWith(RobolectricTestRunner.class)
+public class ToggleAccessibilityServicePreferenceFragmentTest {
+
+ private static final String PLACEHOLDER_PACKAGE_NAME = "com.placeholder.example";
+ private static final String PLACEHOLDER_TILE_CLASS_NAME =
+ PLACEHOLDER_PACKAGE_NAME + "tile.placeholder";
+ private static final String PLACEHOLDER_TILE_CLASS_NAME2 =
+ PLACEHOLDER_PACKAGE_NAME + "tile.placeholder2";
+ private static final ComponentName PLACEHOLDER_TILE_COMPONENT_NAME = new ComponentName(
+ PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME);
+ private static final String PLACEHOLDER_TILE_NAME =
+ PLACEHOLDER_PACKAGE_NAME + "tile.placeholder";
+ private static final String PLACEHOLDER_TILE_NAME2 =
+ PLACEHOLDER_PACKAGE_NAME + "tile.placeholder2";
+
+ private TestToggleAccessibilityServicePreferenceFragment mFragment;
+ private PreferenceScreen mScreen;
+ private Context mContext = ApplicationProvider.getApplicationContext();
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private PreferenceManager mPreferenceManager;
+
+ @Before
+ public void setUpTestFragment() {
+ MockitoAnnotations.initMocks(this);
+
+ mFragment = spy(new TestToggleAccessibilityServicePreferenceFragment());
+ when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
+ when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
+ when(mFragment.getContext()).thenReturn(mContext);
+ mScreen = spy(new PreferenceScreen(mContext, /* attrs= */ null));
+ when(mScreen.getPreferenceManager()).thenReturn(mPreferenceManager);
+ doReturn(mScreen).when(mFragment).getPreferenceScreen();
+ }
+
+ @Test
+ public void getTileName_noTileServiceAssigned_returnNull() {
+ assertThat(mFragment.getTileName()).isNull();
+ }
+
+ @Test
+ public void getTileName_hasOneTileService_haveMatchString() {
+ final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE);
+ final ResolveInfo info = new ResolveInfo();
+ info.serviceInfo = new FakeServiceInfo();
+ info.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
+ info.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME;
+ final ShadowPackageManager shadowPackageManager =
+ Shadows.shadowOf(mContext.getPackageManager());
+ shadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info));
+
+ final CharSequence tileName = mFragment.getTileName();
+ assertThat(tileName.toString()).isEqualTo(PLACEHOLDER_TILE_NAME);
+ }
+
+ @Test
+ public void getTileName_hasTwoTileServices_haveMatchString() {
+ final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE);
+ final ResolveInfo info = new ResolveInfo();
+ info.serviceInfo = new FakeServiceInfo();
+ info.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
+ info.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME;
+ final ResolveInfo info2 = new ResolveInfo();
+ info2.serviceInfo = new FakeServiceInfo2();
+ info2.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
+ info2.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME2;
+ final ShadowPackageManager shadowPackageManager =
+ Shadows.shadowOf(mContext.getPackageManager());
+ shadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info, info2));
+
+ final CharSequence tileName = mFragment.getTileName();
+ assertThat(tileName.toString()).isEqualTo(PLACEHOLDER_TILE_NAME);
+ }
+
+ private static class FakeServiceInfo extends ServiceInfo {
+ public String loadLabel(PackageManager mgr) {
+ return PLACEHOLDER_TILE_NAME;
+ }
+ }
+
+ private static class FakeServiceInfo2 extends ServiceInfo {
+ public String loadLabel(PackageManager mgr) {
+ return PLACEHOLDER_TILE_NAME2;
+ }
+ }
+
+ private static class TestToggleAccessibilityServicePreferenceFragment
+ extends ToggleAccessibilityServicePreferenceFragment {
+
+ @Override
+ protected ComponentName getTileComponentName() {
+ return PLACEHOLDER_TILE_COMPONENT_NAME;
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
index 2cec3d1..b6401cf 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
@@ -16,6 +16,7 @@
package com.android.settings.applications.appinfo;
+import static com.android.settings.applications.appinfo.AppInfoDashboardFragment.ACCESS_RESTRICTED_SETTINGS;
import static com.android.settings.applications.appinfo.AppInfoDashboardFragment.ARG_PACKAGE_NAME;
import static com.android.settings.applications.appinfo.AppInfoDashboardFragment.UNINSTALL_ALL_USERS_MENU;
import static com.android.settings.applications.appinfo.AppInfoDashboardFragment.UNINSTALL_UPDATES;
@@ -165,8 +166,10 @@
Menu menu = mock(Menu.class);
final MenuItem uninstallUpdatesMenuItem = mock(MenuItem.class);
final MenuItem uninstallForAllMenuItem = mock(MenuItem.class);
+ final MenuItem accessRestrictedMenuItem = mock(MenuItem.class);
when(menu.findItem(UNINSTALL_UPDATES)).thenReturn(uninstallUpdatesMenuItem);
when(menu.findItem(UNINSTALL_ALL_USERS_MENU)).thenReturn(uninstallForAllMenuItem);
+ when(menu.findItem(ACCESS_RESTRICTED_SETTINGS)).thenReturn(accessRestrictedMenuItem);
// Setup work to prevent NPE
final ApplicationInfo info = new ApplicationInfo();
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingServiceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingServiceTest.java
index e73b447..3194e55 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingServiceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingServiceTest.java
@@ -106,7 +106,7 @@
mBluetoothPairingService.onStartCommand(intent, /* flags */ 0, /* startId */ 0);
- verify(mDevice).cancelPairing();
+ verify(mDevice).cancelBondProcess();
verify(mNm).cancel(mBluetoothPairingService.NOTIFICATION_ID);
}
diff --git a/tests/robotests/src/com/android/settings/datausage/WifiDataUsageSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datausage/WifiDataUsageSummaryPreferenceControllerTest.java
new file mode 100644
index 0000000..711f6d7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/datausage/WifiDataUsageSummaryPreferenceControllerTest.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2022 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.datausage;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+import android.net.NetworkPolicyManager;
+import android.telephony.TelephonyManager;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.net.DataUsageController;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.HashSet;
+import java.util.Set;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiDataUsageSummaryPreferenceControllerTest {
+
+ @Rule
+ public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+ @Spy
+ Context mContext = ApplicationProvider.getApplicationContext();
+ @Mock
+ FragmentActivity mActivity;
+ @Mock
+ Lifecycle mLifecycle;
+ @Mock
+ TelephonyManager mTelephonyManager;
+ @Mock
+ NetworkPolicyManager mNetworkPolicyManager;
+ @Mock
+ DataUsageSummaryPreference mSummaryPreference;
+ @Mock
+ DataUsageController mDataUsageController;
+ @Mock
+ DataUsageController.DataUsageInfo mDataUsageInfo;
+
+ WifiDataUsageSummaryPreferenceController mController;
+ Set<String> mAllNetworkKeys = new HashSet<>();
+
+ @Before
+ public void setUp() {
+ doReturn(mContext.getResources()).when(mActivity).getResources();
+ doReturn(mTelephonyManager).when(mActivity).getSystemService(TelephonyManager.class);
+ doReturn(mNetworkPolicyManager).when(mActivity)
+ .getSystemService(NetworkPolicyManager.class);
+ doNothing().when(mSummaryPreference).setWifiMode(anyBoolean(), anyString(), anyBoolean());
+ doReturn(mDataUsageInfo).when(mDataUsageController).getDataUsageInfo(any());
+
+ mController = spy(new WifiDataUsageSummaryPreferenceController(mActivity, mLifecycle, null,
+ mAllNetworkKeys));
+ doReturn(mDataUsageController).when(mController).createDataUsageController(any());
+ }
+
+ @Test
+ public void updateState_nullOfDataUsageController_shouldNotCrash() {
+ mController.mDataUsageController = null;
+
+ mController.updateState(mSummaryPreference);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AbsBasePrivacySettingsPreference.java b/tests/robotests/src/com/android/settings/enterprise/AbsBasePrivacySettingsPreference.java
index 5cf2224..34b218a 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AbsBasePrivacySettingsPreference.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AbsBasePrivacySettingsPreference.java
@@ -84,18 +84,6 @@
protected 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);
+ assertThat(controllers).isEmpty();
}
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
index 8d5e4da..59e9e3c 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerBaseTest.java
@@ -18,13 +18,15 @@
import static com.google.common.truth.Truth.assertThat;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-
-import java.util.Date;
import org.robolectric.RobolectricTestRunner;
+import java.util.Date;
+
@RunWith(RobolectricTestRunner.class)
+@Ignore
public class AdminActionPreferenceControllerBaseTest
extends AdminActionPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java
index 2ff9d17..018a64a 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java
@@ -28,6 +28,7 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -36,6 +37,7 @@
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
+@Ignore
public final class AlwaysOnVpnCurrentUserPreferenceControllerTest {
private static final String VPN_SET_DEVICE = "VPN set";
diff --git a/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
index 34853c6..0b5261b 100644
--- a/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
@@ -20,6 +20,7 @@
import static org.mockito.Mockito.when;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -27,6 +28,7 @@
import java.util.Date;
@RunWith(RobolectricTestRunner.class)
+@Ignore
public class BugReportsPreferenceControllerTest
extends AdminActionPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java
index 799dd7e..130b3b9 100644
--- a/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/CaCertsCurrentUserPreferenceControllerTest.java
@@ -25,11 +25,13 @@
import com.android.settings.R;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
+@Ignore
public class CaCertsCurrentUserPreferenceControllerTest
extends CaCertsPreferenceControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
index e3f58f4..2b64c19 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
@@ -50,6 +50,7 @@
import com.google.common.collect.ImmutableList;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatcher;
@@ -139,6 +140,7 @@
}
@Test
+ @Ignore
public void testGetDeviceOwnerDisclosure() {
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null);
assertThat(mProvider.getDeviceOwnerDisclosure()).isNull();
diff --git a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
index facdce5..dc9fb0c 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
@@ -28,6 +28,7 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -58,6 +59,7 @@
}
@Test
+ @Ignore
public void testUpdateState() {
final Preference preference = new Preference(mContext, null, 0, 0);
diff --git a/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java
index 89c208c..466ec0e 100644
--- a/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/NetworkLogsPreferenceControllerTest.java
@@ -20,13 +20,15 @@
import static org.mockito.Mockito.when;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-
-import java.util.Date;
import org.robolectric.RobolectricTestRunner;
+import java.util.Date;
+
@RunWith(RobolectricTestRunner.class)
+@Ignore
public class NetworkLogsPreferenceControllerTest extends AdminActionPreferenceControllerTestBase {
@Override
diff --git a/tests/robotests/src/com/android/settings/enterprise/PrivacyPreferenceControllerHelperTest.java b/tests/robotests/src/com/android/settings/enterprise/PrivacyPreferenceControllerHelperTest.java
index cbd6392e..e8a9e17 100644
--- a/tests/robotests/src/com/android/settings/enterprise/PrivacyPreferenceControllerHelperTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/PrivacyPreferenceControllerHelperTest.java
@@ -33,6 +33,7 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -73,6 +74,7 @@
}
@Test
+ @Ignore
public void testUpdateState_noDeviceOwnerName_useGenericPreferenceSummary() {
final Preference preference = new Preference(mContext, null, 0, 0);
when(mContext.getString(R.string.enterprise_privacy_settings_summary_generic))
@@ -86,6 +88,7 @@
}
@Test
+ @Ignore
public void testUpdateState_deviceOwnerName_usePreferenceSummaryWithDeviceOwnerName() {
final Preference preference = new Preference(mContext, null, 0, 0);
when(mContext.getResources().getString(
diff --git a/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java
index 8612ee7..98bc82b 100644
--- a/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/SecurityLogsPreferenceControllerTest.java
@@ -20,13 +20,15 @@
import static org.mockito.Mockito.when;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-
-import java.util.Date;
import org.robolectric.RobolectricTestRunner;
+import java.util.Date;
+
@RunWith(RobolectricTestRunner.class)
+@Ignore
public class SecurityLogsPreferenceControllerTest extends AdminActionPreferenceControllerTestBase {
@Override
diff --git a/tests/robotests/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragmentTest.java b/tests/robotests/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragmentTest.java
index c6c6a66..c6e7a97 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragmentTest.java
@@ -20,7 +20,9 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -31,6 +33,7 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.os.Bundle;
+import android.os.UserHandle;
import android.provider.SearchIndexableResource;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
@@ -43,6 +46,7 @@
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.testutils.shadow.ShadowInputMethodManagerWithMethodList;
import com.android.settings.testutils.shadow.ShadowSecureSettings;
+import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.inputmethod.InputMethodPreference;
import com.android.settingslib.inputmethod.InputMethodSettingValuesWrapper;
@@ -62,7 +66,8 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {
ShadowSecureSettings.class,
- ShadowInputMethodManagerWithMethodList.class
+ ShadowInputMethodManagerWithMethodList.class,
+ ShadowUserManager.class
})
public class AvailableVirtualKeyboardFragmentTest {
@@ -170,6 +175,7 @@
when(mFragment.getPreferenceScreen()).thenReturn(mPreferenceScreen);
when(mPreferenceManager.getContext()).thenReturn(mContext);
when(mContext.getSystemService(InputMethodManager.class)).thenReturn(mInputMethodManager);
+ doReturn(mContext).when(mContext).createContextAsUser(any(UserHandle.class), anyInt());
}
private List<InputMethodInfo> createFakeInputMethodInfoList(final String name, int num) {
diff --git a/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java
index 8a81908..bf4811b 100644
--- a/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java
@@ -31,6 +31,7 @@
import androidx.test.core.app.ApplicationProvider;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -72,6 +73,7 @@
}
@Test
+ @Ignore
public void lifecycle_shouldRegisterReceiverOnStart() {
mController.onStart();
diff --git a/tests/robotests/src/com/android/settings/security/ChangeScreenLockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/ChangeScreenLockPreferenceControllerTest.java
index 9913e55..bf9606d 100644
--- a/tests/robotests/src/com/android/settings/security/ChangeScreenLockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/ChangeScreenLockPreferenceControllerTest.java
@@ -40,6 +40,7 @@
import com.android.settings.widget.GearPreference;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -50,6 +51,7 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowUtils.class)
+@Ignore
public class ChangeScreenLockPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
index 29a62ea..72bdd39 100644
--- a/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
@@ -21,13 +21,13 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;
+import android.content.ComponentName;
import android.content.Context;
import androidx.preference.Preference;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
-import com.android.settings.security.trustagent.TrustAgentManager.TrustAgentComponentInfo;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
@@ -46,8 +46,6 @@
public class ManageTrustAgentsPreferenceControllerTest {
@Mock
- private TrustAgentManager mTrustAgentManager;
- @Mock
private LockPatternUtils mLockPatternUtils;
private FakeFeatureFactory mFeatureFactory;
@@ -62,8 +60,6 @@
mFeatureFactory = FakeFeatureFactory.setupForTest();
when(mFeatureFactory.securityFeatureProvider.getLockPatternUtils(mContext))
.thenReturn(mLockPatternUtils);
- when(mFeatureFactory.securityFeatureProvider.getTrustAgentManager())
- .thenReturn(mTrustAgentManager);
mController = new ManageTrustAgentsPreferenceController(mContext, "key");
mPreference = new Preference(mContext);
mPreference.setKey(mController.getPreferenceKey());
@@ -94,8 +90,7 @@
@Test
public void updateState_isSecure_noTrustAgent_shouldShowGenericSummary() {
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
- when(mTrustAgentManager.getActiveTrustAgents(mContext, mLockPatternUtils))
- .thenReturn(new ArrayList<>());
+ when(mLockPatternUtils.getEnabledTrustAgents(anyInt())).thenReturn(new ArrayList<>());
mController.updateState(mPreference);
@@ -107,8 +102,8 @@
@Test
public void updateState_isSecure_hasTrustAgent_shouldShowDetailedSummary() {
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
- when(mTrustAgentManager.getActiveTrustAgents(mContext, mLockPatternUtils))
- .thenReturn(Collections.singletonList(new TrustAgentComponentInfo()));
+ when(mLockPatternUtils.getEnabledTrustAgents(anyInt())).thenReturn(
+ Collections.singletonList(new ComponentName("packageName", "className")));
mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/testutils/BedtimeSettingsUtils.java b/tests/robotests/src/com/android/settings/testutils/BedtimeSettingsUtils.java
index 59c501b..ac55334 100644
--- a/tests/robotests/src/com/android/settings/testutils/BedtimeSettingsUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/BedtimeSettingsUtils.java
@@ -17,6 +17,7 @@
package com.android.settings.testutils;
import static android.provider.Settings.ACTION_BEDTIME_SETTINGS;
+import static android.util.FeatureFlagUtils.SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME;
import static org.robolectric.Shadows.shadowOf;
@@ -25,6 +26,7 @@
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ResolveInfo;
+import android.util.FeatureFlagUtils;
/** A helper class for installing bedtime settings activity. */
public final class BedtimeSettingsUtils {
@@ -35,6 +37,8 @@
}
public void installBedtimeSettings(String wellbeingPackage, boolean enabled) {
+ FeatureFlagUtils.setEnabled(mContext, SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME,
+ true /* enabled */);
Intent bedtimeSettingsIntent = new Intent(ACTION_BEDTIME_SETTINGS)
.setPackage(wellbeingPackage);
ResolveInfo bedtimeResolveInfo = new ResolveInfo();
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
index 20547d7..74e3971 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
@@ -40,7 +40,7 @@
private static Map<Integer, Integer> sUserToProfileComplexityMap = new HashMap<>();
private static Map<Integer, PasswordMetrics> sUserToMetricsMap = new HashMap<>();
private static Map<Integer, PasswordMetrics> sUserToProfileMetricsMap = new HashMap<>();
-
+ private static Map<Integer, Boolean> sUserToIsSecureMap = new HashMap<>();
@Resetter
public static void reset() {
@@ -48,6 +48,7 @@
sUserToProfileComplexityMap.clear();
sUserToMetricsMap.clear();
sUserToProfileMetricsMap.clear();
+ sUserToIsSecureMap.clear();
sDeviceEncryptionEnabled = false;
}
@@ -57,8 +58,16 @@
}
@Implementation
- protected boolean isSecure(int id) {
- return true;
+ protected boolean isSecure(int userId) {
+ Boolean isSecure = sUserToIsSecureMap.get(userId);
+ if (isSecure == null) {
+ return true;
+ }
+ return isSecure;
+ }
+
+ public static void setIsSecure(int userId, boolean isSecure) {
+ sUserToIsSecureMap.put(userId, isSecure);
}
@Implementation
@@ -144,4 +153,13 @@
sUserToProfileMetricsMap.put(UserHandle.myUserId(), metrics);
}
+ @Implementation
+ public boolean isLockScreenDisabled(int userId) {
+ return false;
+ }
+
+ @Implementation
+ public boolean isSeparateProfileChallengeEnabled(int userHandle) {
+ return false;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java
index dc42515..ea51370 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java
@@ -44,6 +44,8 @@
private static boolean sIsSupportsMultipleUsers;
+ private static final int PRIMARY_USER_ID = 0;
+
private final List<String> mBaseRestrictions = new ArrayList<>();
private final List<String> mGuestRestrictions = new ArrayList<>();
private final Map<String, List<EnforcingUser>> mRestrictionSources = new HashMap<>();
@@ -218,4 +220,10 @@
mEnabledTypes.remove(type);
}
}
+
+ @Implementation
+ protected UserInfo getPrimaryUser() {
+ return new UserInfo(PRIMARY_USER_ID, null, null,
+ UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY);
+ }
}
diff --git a/tests/unit/OWNERS b/tests/unit/OWNERS
index 4123742..8a7a27e 100644
--- a/tests/unit/OWNERS
+++ b/tests/unit/OWNERS
@@ -1,2 +1,2 @@
-# Additional reviewers for this and subdirectories.
-goldmanj@google.com
+# We do not guard tests - everyone is welcomed to contribute to tests.
+per-file *.java=*
\ No newline at end of file
diff --git a/tests/unit/src/com/android/settings/notification/OWNERS b/tests/unit/src/com/android/settings/notification/OWNERS
new file mode 100644
index 0000000..a2ae9ce
--- /dev/null
+++ b/tests/unit/src/com/android/settings/notification/OWNERS
@@ -0,0 +1,5 @@
+# Default reviewers for this and subdirectories.
+beverlyt@google.com
+dsandler@android.com
+juliacr@google.com
+yurilin@google.com
\ No newline at end of file