Snap for 8167364 from 6b8ddccb7a to tm-release

Change-Id: Ib8df81d0c58c5241f55a8bbdebc59ea511bd444b
This commit is contained in:
Android Build Coastguard Worker
2022-02-10 02:10:10 +00:00
42 changed files with 955 additions and 129 deletions

View File

@@ -32,6 +32,7 @@
<TextView <TextView
style="@style/SudDescription.Glif" style="@style/SudDescription.Glif"
android:id="@+id/forgot_password_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"

View File

@@ -12032,20 +12032,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] --> <!-- 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> <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] --> <!-- 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_exposure_category">Types of information your device administrator can see</string> <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>
<!-- Label explaining that the device administrator can see data associated on the user's financed device. [CHAR LIMIT=NONE] --> <!-- Section header. This section shows what restrictions will be enforced on the device when it is financed. [CHAR LIMIT=60] -->
<string name="financed_privacy_data">Data associated with your account, such as email and calendar info</string> <string name="financed_privacy_restrictions_category">If your device is financed, you can\u2019t:</string>
<!-- Section header. This section shows what changes a device administrator made to a financed device. [CHAR LIMIT=60] --> <!-- Label explaining that installing apps from unknown sources beyond Play Store. [CHAR LIMIT=60]-->
<string name="financed_privacy_exposure_changes_category">Changes made by your device administrator</string> <string name="financed_privacy_install_apps">Install apps from outside the Play Store</string>
<!-- Label explaining that the device admin can lock the device and change the user's password on their financed device. [CHAR LIMIT=NONE] --> <!-- Label explaining that rebooting the device into safe mode. [CHAR LIMIT=60]-->
<string name="financed_privacy_lock_device">Device administrator can lock this device and reset password</string> <string name="financed_privacy_safe_mode">Reboot your device into safe mode</string>
<!-- Label explaining that the device admin can wipe the device remotely for a financed device. [CHAR LIMIT=NONE] --> <!-- Label explaining that adding more than one user into the device. [CHAR LIMIT=60]-->
<string name="financed_privacy_wipe_device">Device administrator can delete all device data</string> <string name="financed_privacy_multi_users">Add multiple users to your device</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] --> <!-- Label explaining that updating the date and time on the device. [CHAR LIMIT=60] -->
<string name="financed_privacy_failed_password_wipe_device">Failed password attempts before deleting device data</string> <string name="financed_privacy_config_date_time">Change date, time, and time zones</string>
<!-- Financed Privacy settings activity header, summarizing the changes a credit provider can make to a financed device. [CHAR LIMIT=NONE] --> <!-- Label explaining that turning on the developer options on the device. [CHAR LIMIT=40]-->
<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> <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 &amp; 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. --> <!-- 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] --> <!-- Title for the apps that have been set as default handlers of camera-related intents. [CHAR LIMIT=30] -->

View File

@@ -19,66 +19,102 @@
xmlns:settings="http://schemas.android.com/apk/res-auto" xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/financed_privacy_settings"> 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:order="200"
android:title="@string/financed_privacy_exposure_category" android:title="@string/financed_privacy_credit_provider_capabilities_category"
android:contentDescription="@string/financed_privacy_exposure_category"> android:contentDescription="@string/financed_privacy_credit_provider_capabilities_category">
<Preference android:key="enterprise_privacy_enterprise_data" <Preference android:key="financed_privacy_IMEI"
android:order="210" android:order="210"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:title="@string/financed_privacy_data" android:title="@string/financed_privacy_IMEI"
android:selectable="false"/> android:selectable="false" />
<Preference android:key="enterprise_privacy_installed_packages" <Preference android:key="financed_privacy_factory_reset"
android:order="220" android:order="220"
android:title="@string/enterprise_privacy_installed_packages" android:layout_height="wrap_content"
android:selectable="false"/> android:title="@string/financed_privacy_factory_reset"
<Preference android:key="enterprise_privacy_usage_stats" android:selectable="false" />
android:order="230"
android:title="@string/enterprise_privacy_usage_stats"
android:selectable="false"/>
<Preference android:key="network_logs"
android:order="240"
android:title="@string/enterprise_privacy_network_logs"
android:selectable="false"/>
<Preference android:key="bug_reports"
android:order="250"
android:title="@string/enterprise_privacy_bug_reports"
android:selectable="false"/>
<Preference android:key="security_logs"
android:order="260"
android:title="@string/enterprise_privacy_security_logs"
android:selectable="false"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/financed_privacy_exposure_changes_category" <PreferenceCategory android:key="locked_mode_category"
android:order="300" android:order="300"
android:key="exposure_changes_category"> android:title="@string/financed_privacy_locked_mode_category"
<Preference android:fragment="com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages" android:contentDescription="@string/financed_privacy_locked_mode_category">
<Preference android:key="financed_privacy_emergency_calls"
android:order="310" android:order="310"
android:key="number_enterprise_installed_packages" android:layout_height="wrap_content"
android:title="@string/enterprise_privacy_enterprise_installed_packages"/> 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>
<PreferenceCategory android:key="device_access_category" <PreferenceCategory android:key="fully_paid_category"
android:order="500" android:order="400"
android:title="@string/enterprise_privacy_device_access_category"> android:title="@string/financed_privacy_fully_paid_category"
<Preference android:key="enterprise_privacy_lock_device" android:contentDescription="@string/financed_privacy_fully_paid_category">
android:order="510" <Preference android:key="financed_privacy_restrictions_removed"
android:title="@string/financed_privacy_lock_device" android:order="410"
android:selectable="false"/> android:layout_height="wrap_content"
<Preference android:key="enterprise_privacy_wipe_device" android:title="@string/financed_privacy_restrictions_removed"
android:order="520" android:selectable="false" />
android:title="@string/financed_privacy_wipe_device" <Preference android:key="financed_privacy_uninstall_creditor_app"
android:selectable="false"/> android:order="420"
<Preference android:key="failed_password_wipe_current_user" android:layout_height="wrap_content"
android:order="530" android:title="@string/financed_privacy_uninstall_creditor_app"
android:title="@string/financed_privacy_failed_password_wipe_device" android:selectable="false" />
android:selectable="false"/>
</PreferenceCategory> </PreferenceCategory>
<com.android.settingslib.widget.FooterPreference
android:key="financed_privacy_footer"
android:title="@string/financed_privacy_header"
android:selectable="false"
settings:searchable="false"/>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -32,10 +32,12 @@
android:key="interact_across_profiles_settings_switch" /> android:key="interact_across_profiles_settings_switch" />
<Preference <Preference
android:key="interact_across_profiles_summary_1"
android:summary="@string/interact_across_profiles_summary_1" android:summary="@string/interact_across_profiles_summary_1"
android:selectable="false" /> android:selectable="false" />
<Preference <Preference
android:key="interact_across_profiles_summary_2"
android:summary="@string/interact_across_profiles_summary_2" android:summary="@string/interact_across_profiles_summary_2"
android:selectable="false" /> android:selectable="false" />

View File

@@ -221,6 +221,13 @@ public class AccessibilityDetailsSettingsFragment extends InstrumentedFragment {
extras.putString(AccessibilitySettings.EXTRA_SETTINGS_COMPONENT_NAME, extras.putString(AccessibilitySettings.EXTRA_SETTINGS_COMPONENT_NAME,
new ComponentName(packageName, settingsClassName).flattenToString()); 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.putParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME, componentName);
extras.putInt(AccessibilitySettings.EXTRA_ANIMATED_IMAGE_RES, info.getAnimatedImageRes()); extras.putInt(AccessibilitySettings.EXTRA_ANIMATED_IMAGE_RES, info.getAnimatedImageRes());

View File

@@ -46,6 +46,7 @@ import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes; import androidx.annotation.RawRes;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
@@ -125,9 +126,15 @@ public final class AccessibilityGestureNavigationTutorial {
} }
static AlertDialog createAccessibilityTutorialDialog(Context context, int shortcutTypes) { 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) return new AlertDialog.Builder(context)
.setView(createShortcutNavigationContentView(context, shortcutTypes)) .setView(createShortcutNavigationContentView(context, shortcutTypes))
.setNegativeButton(R.string.accessibility_tutorial_dialog_button, mOnClickListener) .setNegativeButton(R.string.accessibility_tutorial_dialog_button,
negativeButtonListener)
.create(); .create();
} }

View File

@@ -97,6 +97,7 @@ public class AccessibilitySettings extends DashboardFragment {
static final String EXTRA_SETTINGS_TITLE = "settings_title"; static final String EXTRA_SETTINGS_TITLE = "settings_title";
static final String EXTRA_COMPONENT_NAME = "component_name"; static final String EXTRA_COMPONENT_NAME = "component_name";
static final String EXTRA_SETTINGS_COMPONENT_NAME = "settings_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_VIDEO_RAW_RESOURCE_ID = "video_resource";
static final String EXTRA_LAUNCHED_FROM_SUW = "from_suw"; static final String EXTRA_LAUNCHED_FROM_SUW = "from_suw";
static final String EXTRA_ANIMATED_IMAGE_RES = "animated_image_res"; static final String EXTRA_ANIMATED_IMAGE_RES = "animated_image_res";
@@ -573,11 +574,13 @@ public class AccessibilitySettings extends DashboardFragment {
serviceEnabled); serviceEnabled);
final String htmlDescription = info.loadHtmlDescription(mPm); final String htmlDescription = info.loadHtmlDescription(mPm);
final String settingsClassName = info.getSettingsActivityName(); final String settingsClassName = info.getSettingsActivityName();
final String tileServiceClassName = info.getTileServiceClassName();
putBasicExtras(preference, prefKey, title, description, imageRes, htmlDescription, putBasicExtras(preference, prefKey, title, description, imageRes, htmlDescription,
componentName); componentName);
putServiceExtras(preference, resolveInfo, serviceEnabled); putServiceExtras(preference, resolveInfo, serviceEnabled);
putSettingsExtras(preference, packageName, settingsClassName); putSettingsExtras(preference, packageName, settingsClassName);
putTileServiceExtras(preference, packageName, tileServiceClassName);
preferenceList.add(preference); preferenceList.add(preference);
} }
@@ -631,10 +634,13 @@ public class AccessibilitySettings extends DashboardFragment {
final int imageRes = info.getAnimatedImageRes(); final int imageRes = info.getAnimatedImageRes();
final String htmlDescription = info.loadHtmlDescription(mPm); final String htmlDescription = info.loadHtmlDescription(mPm);
final String settingsClassName = info.getSettingsActivityName(); final String settingsClassName = info.getSettingsActivityName();
final String tileServiceClassName = info.getTileServiceClassName();
putBasicExtras(preference, prefKey, title, description, imageRes, htmlDescription, putBasicExtras(preference, prefKey, title, description, imageRes, htmlDescription,
componentName); componentName);
putSettingsExtras(preference, componentName.getPackageName(), settingsClassName); putSettingsExtras(preference, componentName.getPackageName(), settingsClassName);
putTileServiceExtras(preference, componentName.getPackageName(),
tileServiceClassName);
preferenceList.add(preference); preferenceList.add(preference);
} }
@@ -730,7 +736,11 @@ public class AccessibilitySettings extends DashboardFragment {
/** /**
* Puts the service extras into {@link RestrictedPreference}'s getExtras(). * 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, private void putServiceExtras(RestrictedPreference preference, ResolveInfo resolveInfo,
Boolean serviceEnabled) { Boolean serviceEnabled) {
@@ -743,7 +753,12 @@ public class AccessibilitySettings extends DashboardFragment {
/** /**
* Puts the settings extras into {@link RestrictedPreference}'s getExtras(). * 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, private void putSettingsExtras(RestrictedPreference preference, String packageName,
String settingsClassName) { String settingsClassName) {
@@ -756,5 +771,27 @@ public class AccessibilitySettings extends DashboardFragment {
new ComponentName(packageName, settingsClassName).flattenToString()); 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());
}
}
} }
} }

View File

@@ -20,9 +20,11 @@ import static com.android.settings.accessibility.AccessibilityStatsLogUtils.logA
import android.accessibilityservice.AccessibilityShortcutInfo; import android.accessibilityservice.AccessibilityShortcutInfo;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.app.Dialog;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.net.Uri; import android.net.Uri;
@@ -51,6 +53,7 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
private static final String TAG = "LaunchA11yActivity"; private static final String TAG = "LaunchA11yActivity";
private static final String EMPTY_STRING = ""; private static final String EMPTY_STRING = "";
protected static final String KEY_LAUNCH_PREFERENCE = "launch_preference"; protected static final String KEY_LAUNCH_PREFERENCE = "launch_preference";
private ComponentName mTileComponentName;
@Override @Override
public int getMetricsCategory() { public int getMetricsCategory() {
@@ -106,6 +109,13 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
AccessibilitySettings.EXTRA_SETTINGS_TITLE); AccessibilitySettings.EXTRA_SETTINGS_TITLE);
mSettingsIntent = TextUtils.isEmpty(settingsTitle) ? null : getSettingsIntent(arguments); mSettingsIntent = TextUtils.isEmpty(settingsTitle) ? null : getSettingsIntent(arguments);
mSettingsTitle = (mSettingsIntent == null) ? null : settingsTitle; 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 @Override
@@ -116,13 +126,31 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
@Override @Override
ComponentName getTileComponentName() { ComponentName getTileComponentName() {
return null; return mTileComponentName;
} }
@Override @Override
CharSequence getTileName() { CharSequence getTileName() {
final ComponentName componentName = getTileComponentName();
if (componentName == null) {
return 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 @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
@@ -208,4 +236,22 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
return settingsIntent; 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());
}
} }

View File

@@ -65,6 +65,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
private static final String EMPTY_STRING = ""; private static final String EMPTY_STRING = "";
private Dialog mWarningDialog; private Dialog mWarningDialog;
private ComponentName mTileComponentName;
private BroadcastReceiver mPackageRemovedReceiver; private BroadcastReceiver mPackageRemovedReceiver;
private boolean mDisabledStateLogged = false; private boolean mDisabledStateLogged = false;
private long mStartTimeMillsForLogging = 0; private long mStartTimeMillsForLogging = 0;
@@ -168,9 +169,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends
@Override @Override
public Dialog onCreateDialog(int dialogId) { public Dialog onCreateDialog(int dialogId) {
switch (dialogId) {
case DialogEnums.ENABLE_WARNING_FROM_TOGGLE: {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo(); final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
switch (dialogId) {
case DialogEnums.ENABLE_WARNING_FROM_TOGGLE:
if (info == null) { if (info == null) {
return null; return null;
} }
@@ -178,10 +179,8 @@ public class ToggleAccessibilityServicePreferenceFragment extends
.createCapabilitiesDialog(getPrefContext(), info, .createCapabilitiesDialog(getPrefContext(), info,
this::onDialogButtonFromEnableToggleClicked, this::onDialogButtonFromEnableToggleClicked,
this::onDialogButtonFromUninstallClicked); this::onDialogButtonFromUninstallClicked);
break; return mWarningDialog;
} case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE:
case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE: {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
if (info == null) { if (info == null) {
return null; return null;
} }
@@ -189,10 +188,8 @@ public class ToggleAccessibilityServicePreferenceFragment extends
.createCapabilitiesDialog(getPrefContext(), info, .createCapabilitiesDialog(getPrefContext(), info,
this::onDialogButtonFromShortcutToggleClicked, this::onDialogButtonFromShortcutToggleClicked,
this::onDialogButtonFromUninstallClicked); this::onDialogButtonFromUninstallClicked);
break; return mWarningDialog;
} case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT:
case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT: {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
if (info == null) { if (info == null) {
return null; return null;
} }
@@ -200,23 +197,24 @@ public class ToggleAccessibilityServicePreferenceFragment extends
.createCapabilitiesDialog(getPrefContext(), info, .createCapabilitiesDialog(getPrefContext(), info,
this::onDialogButtonFromShortcutClicked, this::onDialogButtonFromShortcutClicked,
this::onDialogButtonFromUninstallClicked); this::onDialogButtonFromUninstallClicked);
break; return mWarningDialog;
} case DialogEnums.DISABLE_WARNING_FROM_TOGGLE:
case DialogEnums.DISABLE_WARNING_FROM_TOGGLE: {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
if (info == null) { if (info == null) {
return null; return null;
} }
mWarningDialog = AccessibilityServiceWarning mWarningDialog = AccessibilityServiceWarning
.createDisableDialog(getPrefContext(), info, .createDisableDialog(getPrefContext(), info,
this::onDialogButtonFromDisableToggleClicked); this::onDialogButtonFromDisableToggleClicked);
break;
}
default: {
mWarningDialog = super.onCreateDialog(dialogId);
}
}
return mWarningDialog; 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);
}
} }
@Override @Override
@@ -243,13 +241,17 @@ public class ToggleAccessibilityServicePreferenceFragment extends
@Override @Override
ComponentName getTileComponentName() { ComponentName getTileComponentName() {
return null; return mTileComponentName;
} }
@Override @Override
CharSequence getTileName() { CharSequence getTileName() {
final ComponentName componentName = getTileComponentName();
if (componentName == null) {
return null; return null;
} }
return loadTileLabel(getPrefContext(), componentName);
}
@Override @Override
protected void updateSwitchBarToggleSwitch() { protected void updateSwitchBarToggleSwitch() {
@@ -386,6 +388,12 @@ public class ToggleAccessibilityServicePreferenceFragment extends
mPackageName = getAccessibilityServiceInfo().getResolveInfo().loadLabel( mPackageName = getAccessibilityServiceInfo().getResolveInfo().loadLabel(
getPackageManager()); 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); mStartTimeMillsForLogging = arguments.getLong(AccessibilitySettings.EXTRA_TIME_FOR_LOGGING);
} }
@@ -488,6 +496,23 @@ public class ToggleAccessibilityServicePreferenceFragment extends
mWarningDialog.dismiss(); 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) { void onDialogButtonFromShortcutClicked(View view) {
final int viewId = view.getId(); final int viewId = view.getId();
if (viewId == R.id.permission_enable_allow_button) { if (viewId == R.id.permission_enable_allow_button) {

View File

@@ -25,7 +25,9 @@ import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.icu.text.CaseMap; import android.icu.text.CaseMap;
import android.net.Uri; import android.net.Uri;
@@ -33,6 +35,7 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.UserHandle; import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
import android.service.quicksettings.TileService;
import android.text.Html; import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@@ -798,6 +801,19 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
PreferredShortcuts.saveUserShortcutType(getPrefContext(), shortcut); PreferredShortcuts.saveUserShortcutType(getPrefContext(), shortcut);
} }
/**
* 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 the quick settings tooltip if the quick settings service is assigned. The tooltip only
* shows once. * shows once.
@@ -830,4 +846,20 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
tileComponentName); tileComponentName);
mNeedsQSTooltipReshow = false; 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;
}
} }

View File

@@ -16,6 +16,12 @@
package com.android.settings.accounts; 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.app.settings.SettingsEnums;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@@ -78,6 +84,17 @@ public class ManagedProfileSettings extends DashboardFragment {
super.onCreate(icicle); super.onCreate(icicle);
mManagedProfileBroadcastReceiver = new ManagedProfileBroadcastReceiver(); mManagedProfileBroadcastReceiver = new ManagedProfileBroadcastReceiver();
mManagedProfileBroadcastReceiver.register(getActivity()); 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 @Override

View File

@@ -16,6 +16,8 @@
package com.android.settings.applications.appinfo; 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 static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.Activity; import android.app.Activity;
@@ -238,6 +240,8 @@ public class AppInfoDashboardFragment extends DashboardFragment
startListeningToPackageRemove(); startListeningToPackageRemove();
setHasOptionsMenu(true); setHasOptionsMenu(true);
replaceEnterpriseStringTitle("interact_across_profiles",
CONNECTED_WORK_AND_PERSONAL_APPS_TITLE, R.string.interact_across_profiles_title);
} }
@Override @Override

View File

@@ -16,7 +16,11 @@
package com.android.settings.applications.specialaccess; 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.app.settings.SettingsEnums;
import android.os.Bundle;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
@@ -33,6 +37,15 @@ public class SpecialAccessSettings extends DashboardFragment {
return TAG; return TAG;
} }
@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 @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.special_access; return R.xml.special_access;

View File

@@ -27,6 +27,8 @@ import static android.app.admin.DevicePolicyResources.Strings.Settings.REMOVE_AN
import static android.app.admin.DevicePolicyResources.Strings.Settings.REMOVE_DEVICE_ADMIN; 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.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_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.USER_ADMIN_POLICIES_WARNING;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_ADMIN_POLICIES_WARNING; import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_ADMIN_POLICIES_WARNING;
@@ -365,6 +367,10 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
mAdminDescription = (TextView)findViewById(R.id.admin_description); mAdminDescription = (TextView)findViewById(R.id.admin_description);
mProfileOwnerWarning = (TextView) findViewById(R.id.profile_owner_warning); 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); mAddMsg = (TextView)findViewById(R.id.add_msg);
mAddMsgExpander = (ImageView) findViewById(R.id.add_msg_expander); mAddMsgExpander = (ImageView) findViewById(R.id.add_msg_expander);
final View.OnClickListener onClickListener = new View.OnClickListener() { final View.OnClickListener onClickListener = new View.OnClickListener() {
@@ -410,6 +416,8 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
}); });
mUninstallButton = (Button) findViewById(R.id.uninstall_button); mUninstallButton = (Button) findViewById(R.id.uninstall_button);
mUninstallButton.setText(mDPM.getString(UNINSTALL_DEVICE_ADMIN,
() -> getString(R.string.uninstall_device_admin)));
mUninstallButton.setFilterTouchesWhenObscured(true); mUninstallButton.setFilterTouchesWhenObscured(true);
mUninstallButton.setOnClickListener(new View.OnClickListener() { mUninstallButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {

View File

@@ -16,7 +16,10 @@
package com.android.settings.applications.specialaccess.deviceadmin; 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.app.settings.SettingsEnums;
import android.os.Bundle;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
@@ -31,6 +34,14 @@ public class DeviceAdminSettings extends DashboardFragment {
return SettingsEnums.DEVICE_ADMIN_SETTINGS; return SettingsEnums.DEVICE_ADMIN_SETTINGS;
} }
@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 @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.device_admin_settings; return R.xml.device_admin_settings;

View File

@@ -17,9 +17,13 @@ package com.android.settings.applications.specialaccess.interactacrossprofiles;
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_DATA;
import static android.app.admin.DevicePolicyResources.Strings.Settings.APP_CAN_ACCESS_PERSONAL_PERMISSIONS; 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.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_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.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_AWARE;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE; import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
import static android.provider.Settings.ACTION_MANAGE_CROSS_PROFILE_ACCESS; import static android.provider.Settings.ACTION_MANAGE_CROSS_PROFILE_ACCESS;
@@ -46,6 +50,7 @@ import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.stats.devicepolicy.DevicePolicyEnums; import android.stats.devicepolicy.DevicePolicyEnums;
import android.util.IconDrawableFactory; import android.util.IconDrawableFactory;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@@ -72,9 +77,11 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
"interact_across_profiles_extra_summary"; "interact_across_profiles_extra_summary";
public static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args"; public static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
public static final String INTENT_KEY = "intent"; public static final String INTENT_KEY = "intent";
private static final String TAG = "InteractAcrossProfilesDetails";
private Context mContext; private Context mContext;
private CrossProfileApps mCrossProfileApps; private CrossProfileApps mCrossProfileApps;
private DevicePolicyManager mDevicePolicyManager;
private UserManager mUserManager; private UserManager mUserManager;
private RestrictedSwitchPreference mSwitchPref; private RestrictedSwitchPreference mSwitchPref;
private LayoutPreference mHeader; private LayoutPreference mHeader;
@@ -94,6 +101,7 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
mContext = getContext(); mContext = getContext();
mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class); mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class);
mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
mUserManager = mContext.getSystemService(UserManager.class); mUserManager = mContext.getSystemService(UserManager.class);
mPackageManager = mContext.getPackageManager(); mPackageManager = mContext.getPackageManager();
@@ -106,6 +114,18 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
mInstallAppIntent = AppStoreUtil.getAppStoreLink(mContext, mPackageName); mInstallAppIntent = AppStoreUtil.getAppStoreLink(mContext, mPackageName);
addPreferencesFromResource(R.xml.interact_across_profiles_permissions_details); 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 = findPreference(INTERACT_ACROSS_PROFILES_SETTINGS_SWITCH);
mSwitchPref.setOnPreferenceClickListener(this); mSwitchPref.setOnPreferenceClickListener(this);
@@ -127,6 +147,19 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
logPageLaunchMetrics(); 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() { private void maybeShowExtraSummary() {
Preference extraSummary = findPreference(INTERACT_ACROSS_PROFILE_EXTRA_SUMMARY_KEY); Preference extraSummary = findPreference(INTERACT_ACROSS_PROFILE_EXTRA_SUMMARY_KEY);
if (extraSummary == null) { if (extraSummary == null) {
@@ -264,7 +297,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
final TextView dialogTitle = dialogView.findViewById( final TextView dialogTitle = dialogView.findViewById(
R.id.interact_across_profiles_consent_dialog_title); R.id.interact_across_profiles_consent_dialog_title);
dialogTitle.setText(mDpm.getString(CONNECT_APPS_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); final TextView appDataSummary = dialogView.findViewById(R.id.app_data_summary);
appDataSummary.setText( appDataSummary.setText(
@@ -280,6 +314,12 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
mAppLabel), mAppLabel),
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()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(dialogView) builder.setView(dialogView)
.setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {

View File

@@ -435,7 +435,7 @@ public class BluetoothPairingController implements OnCheckedChangeListener,
*/ */
public void onCancel() { public void onCancel() {
Log.d(TAG, "Pairing dialog canceled"); Log.d(TAG, "Pairing dialog canceled");
mDevice.cancelPairing(); mDevice.cancelBondProcess();
} }
/** /**

View File

@@ -98,7 +98,7 @@ public final class BluetoothPairingService extends Service {
} else if (action.equals(ACTION_DISMISS_PAIRING)) { } else if (action.equals(ACTION_DISMISS_PAIRING)) {
Log.d(TAG, "Notification cancel " + " (" + Log.d(TAG, "Notification cancel " + " (" +
mDevice.getName() + ")"); mDevice.getName() + ")");
mDevice.cancelPairing(); mDevice.cancelBondProcess();
} else { } else {
int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
BluetoothDevice.ERROR); BluetoothDevice.ERROR);
@@ -144,7 +144,7 @@ public final class BluetoothPairingService extends Service {
createPairingNotification(intent); createPairingNotification(intent);
} else if (TextUtils.equals(action, ACTION_DISMISS_PAIRING)) { } else if (TextUtils.equals(action, ACTION_DISMISS_PAIRING)) {
Log.d(TAG, "Notification cancel " + " (" + mDevice.getName() + ")"); Log.d(TAG, "Notification cancel " + " (" + mDevice.getName() + ")");
mDevice.cancelPairing(); mDevice.cancelBondProcess();
mNm.cancel(NOTIFICATION_ID); mNm.cancel(NOTIFICATION_ID);
stopSelf(); stopSelf();
} else if (TextUtils.equals(action, ACTION_PAIRING_DIALOG)) { } else if (TextUtils.equals(action, ACTION_PAIRING_DIALOG)) {

View File

@@ -16,6 +16,7 @@
package com.android.settings.dashboard; package com.android.settings.dashboard;
import android.app.Activity; import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
@@ -79,6 +80,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
private DashboardTilePlaceholderPreferenceController mPlaceholderPreferenceController; private DashboardTilePlaceholderPreferenceController mPlaceholderPreferenceController;
private boolean mListeningToCategoryChange; private boolean mListeningToCategoryChange;
private List<String> mSuppressInjectedTileKeys; private List<String> mSuppressInjectedTileKeys;
private DevicePolicyManager mDevicePolicyManager;
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
@@ -148,6 +150,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
mDevicePolicyManager = getSystemService(DevicePolicyManager.class);
// Set ComparisonCallback so we get better animation when list changes. // Set ComparisonCallback so we get better animation when list changes.
getPreferenceManager().setPreferenceComparisonCallback( getPreferenceManager().setPreferenceComparisonCallback(
new PreferenceManager.SimplePreferenceComparisonCallback()); new PreferenceManager.SimplePreferenceComparisonCallback());
@@ -566,4 +569,30 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
resolver.unregisterContentObserver(observer); 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)));
}
} }

View File

@@ -53,6 +53,7 @@ public class TimeoutListPreference extends RestrictedListPreference {
super.onPrepareDialogBuilder(builder, listener); super.onPrepareDialogBuilder(builder, listener);
if (mAdmin != null) { if (mAdmin != null) {
builder.setView(R.layout.admin_disabled_other_options_footer); builder.setView(R.layout.admin_disabled_other_options_footer);
// TODO: replace Text on textview with admin_disabled_other_options
} else { } else {
builder.setView(null); builder.setView(null);
} }

View File

@@ -17,11 +17,13 @@
package com.android.settings.display.darkmode; package com.android.settings.display.darkmode;
import static android.provider.Settings.ACTION_BEDTIME_SETTINGS; 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.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.util.FeatureFlagUtils;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -44,6 +46,10 @@ public final class BedtimeSettings {
*/ */
@Nullable @Nullable
public Intent getBedtimeSettingsIntent() { 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( Intent bedtimeSettingsIntent = new Intent(ACTION_BEDTIME_SETTINGS).setPackage(
mWellbeingPackage); mWellbeingPackage);
ResolveInfo bedtimeSettingInfo = mPackageManager.resolveActivity(bedtimeSettingsIntent, ResolveInfo bedtimeSettingInfo = mPackageManager.resolveActivity(bedtimeSettingsIntent,

View File

@@ -16,6 +16,8 @@
package com.android.settings.enterprise; 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.NonNull;
import android.annotation.UserIdInt; import android.annotation.UserIdInt;
import android.app.Activity; import android.app.Activity;
@@ -67,6 +69,13 @@ public final class ActionDisabledByAdminDialogHelper {
.createInstance(mActivity, restriction, .createInstance(mActivity, restriction,
new DeviceAdminStringProviderImpl(mActivity), new DeviceAdminStringProviderImpl(mActivity),
UserHandle.SYSTEM); 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) { private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {

View File

@@ -19,6 +19,7 @@ package com.android.settings.enterprise;
import android.Manifest; import android.Manifest;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.applications.ApplicationFeatureProvider; import com.android.settings.applications.ApplicationFeatureProvider;
@@ -43,6 +44,11 @@ public abstract class ApplicationListFragment extends DashboardFragment
return TAG; return TAG;
} }
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
}
@Override @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.app_list_disclosure_settings; return R.xml.app_list_disclosure_settings;

View File

@@ -20,10 +20,8 @@ import android.content.Context;
import android.provider.SearchIndexableResource; import android.provider.SearchIndexableResource;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.widget.PreferenceCategoryController;
import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.core.AbstractPreferenceController;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -61,18 +59,6 @@ public class PrivacySettingsFinancedPreference implements PrivacySettingsPrefere
*/ */
@Override @Override
public List<AbstractPreferenceController> createPreferenceControllers(boolean async) { public List<AbstractPreferenceController> createPreferenceControllers(boolean async) {
final List<AbstractPreferenceController> controllers = new ArrayList<>(); return Collections.emptyList();
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;
} }
} }

View File

@@ -16,9 +16,12 @@
package com.android.settings.language; 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.Activity;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -70,6 +73,14 @@ public class LanguageAndInputSettings extends DashboardFragment {
activity.setTitle(R.string.language_settings); activity.setTitle(R.string.language_settings);
} }
@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 @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.language_and_input; return R.xml.language_and_input;

View File

@@ -16,6 +16,8 @@
package com.android.settings.location; 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.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.location.SettingInjectorService; import android.location.SettingInjectorService;
@@ -107,6 +109,14 @@ public class LocationSettings extends DashboardFragment implements
return R.xml.location_settings; 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 @Override
protected String getLogTag() { protected String getLogTag() {
return TAG; return TAG;

View File

@@ -16,8 +16,11 @@
package com.android.settings.location; 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.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
@@ -40,6 +43,13 @@ public class LocationWorkProfileSettings extends DashboardFragment {
return R.xml.location_settings_workprofile; return R.xml.location_settings_workprofile;
} }
@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 @Override
protected String getLogTag() { protected String getLogTag() {
return TAG; return TAG;

View File

@@ -16,6 +16,9 @@
package com.android.settings.notification; 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.Activity;
import android.app.Application; import android.app.Application;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
@@ -69,6 +72,17 @@ public class ConfigureNotificationSettings extends DashboardFragment implements
return TAG; return TAG;
} }
@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 @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.configure_notification_settings; return R.xml.configure_notification_settings;

View File

@@ -16,6 +16,8 @@
package com.android.settings.notification; 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.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -97,6 +99,9 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
.findFragmentByTag(TAG); .findFragmentByTag(TAG);
mDialogFragment = dialogFragment; mDialogFragment = dialogFragment;
} }
replaceEnterpriseStringTitle("sound_work_settings",
WORK_PROFILE_SOUND_SETTINGS_SECTION_HEADER,
R.string.sound_work_settings);
} }
@Override @Override

View File

@@ -16,6 +16,12 @@
package com.android.settings.notification; 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.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -64,6 +70,18 @@ public class SoundWorkSettings extends DashboardFragment implements OnActivityRe
mRequestPreference = findPreference(selectedPreference); 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 @Override

View File

@@ -16,12 +16,16 @@
package com.android.settings.password; package com.android.settings.password;
import static android.app.admin.DevicePolicyResources.Strings.Settings.FORGOT_PASSWORD_TEXT;
import android.app.Activity; import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.util.Log; import android.util.Log;
import android.widget.TextView;
import com.android.settings.R; import com.android.settings.R;
@@ -45,6 +49,11 @@ public class ForgotPasswordActivity extends Activity {
} }
setContentView(R.layout.forgot_password_activity); 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); final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
layout.getMixin(FooterBarMixin.class).setPrimaryButton( layout.getMixin(FooterBarMixin.class).setPrimaryButton(
new FooterButton.Builder(this) new FooterButton.Builder(this)

View File

@@ -16,8 +16,15 @@
package com.android.settings.privacy; 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.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
@@ -50,6 +57,24 @@ public class PrivacyDashboardFragment extends DashboardFragment {
return TAG; return TAG;
} }
@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 @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.privacy_dashboard_settings; return R.xml.privacy_dashboard_settings;

View File

@@ -16,9 +16,13 @@
package com.android.settings.security; 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.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.hardware.display.AmbientDisplayConfiguration; import android.hardware.display.AmbientDisplayConfiguration;
import android.os.Bundle;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@@ -75,6 +79,16 @@ public class LockscreenDashboardFragment extends DashboardFragment
return TAG; return TAG;
} }
@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 @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.security_lockscreen_settings; return R.xml.security_lockscreen_settings;

View File

@@ -16,9 +16,17 @@
package com.android.settings.security; 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.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.biometrics.combination.CombinedBiometricProfileStatusPreferenceController; import com.android.settings.biometrics.combination.CombinedBiometricProfileStatusPreferenceController;
@@ -53,6 +61,27 @@ public class SecurityAdvancedSettings extends DashboardFragment {
private static final String CATEGORY_SECURITY_LEGACY_ADVANCED_SETTINGS = private static final String CATEGORY_SECURITY_LEGACY_ADVANCED_SETTINGS =
"com.android.settings.category.ia.legacy_advanced_security"; "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 @Override
public int getMetricsCategory() { public int getMetricsCategory() {
return SettingsEnums.SECURITY_ADVANCED; return SettingsEnums.SECURITY_ADVANCED;

View File

@@ -18,6 +18,7 @@ package com.android.settings.users;
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_MESSAGE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_REMOVE_TITLE; 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.Dialog;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
@@ -89,6 +90,8 @@ public final class UserDialogs {
*/ */
private static View createRemoveManagedUserDialogView(Context context, int userId) { private static View createRemoveManagedUserDialogView(Context context, int userId) {
PackageManager packageManager = context.getPackageManager(); PackageManager packageManager = context.getPackageManager();
DevicePolicyManager devicePolicyManager =
context.getSystemService(DevicePolicyManager.class);
ApplicationInfo mdmApplicationInfo = Utils.getAdminApplicationInfo(context, userId); ApplicationInfo mdmApplicationInfo = Utils.getAdminApplicationInfo(context, userId);
if (mdmApplicationInfo == null) { if (mdmApplicationInfo == null) {
return null; return null;
@@ -102,6 +105,16 @@ public final class UserDialogs {
Drawable badgedApplicationIcon = packageManager.getApplicationIcon(mdmApplicationInfo); Drawable badgedApplicationIcon = packageManager.getApplicationIcon(mdmApplicationInfo);
imageView.setImageDrawable(badgedApplicationIcon); 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 appLabel = packageManager.getApplicationLabel(mdmApplicationInfo);
CharSequence badgedAppLabel = packageManager.getUserBadgedLabel(appLabel, CharSequence badgedAppLabel = packageManager.getUserBadgedLabel(appLabel,
new UserHandle(userId)); new UserHandle(userId));

View File

@@ -22,26 +22,41 @@ import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutT
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; 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.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
/** Tests for {@link AccessibilityGestureNavigationTutorial}. */ /** Tests for {@link AccessibilityGestureNavigationTutorial}. */
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public final class AccessibilityGestureNavigationTutorialTest { 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; private int mShortcutTypes;
@Before @Before
public void setUp() { public void setUp() {
mContext = RuntimeEnvironment.application; mContext.setTheme(R.style.Theme_AppCompat);
mShortcutTypes = /* initial */ 0; mShortcutTypes = /* initial */ 0;
} }
@@ -86,4 +101,28 @@ public final class AccessibilityGestureNavigationTutorialTest {
mShortcutTypes)).hasSize(/* expectedSize= */ 2); mShortcutTypes)).hasSize(/* expectedSize= */ 2);
assertThat(alertDialog).isNotNull(); 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);
}
} }

View File

@@ -0,0 +1,145 @@
/*
* 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_noMatchString() {
final CharSequence tileName = mFragment.getTileName();
assertThat(tileName.toString()).isEqualTo("");
}
@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;
}
}
}

View File

@@ -0,0 +1,145 @@
/*
* 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_noMatchString() {
final CharSequence tileName = mFragment.getTileName();
assertThat(tileName.toString()).isEqualTo("");
}
@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;
}
}
}

View File

@@ -106,7 +106,7 @@ public class BluetoothPairingServiceTest {
mBluetoothPairingService.onStartCommand(intent, /* flags */ 0, /* startId */ 0); mBluetoothPairingService.onStartCommand(intent, /* flags */ 0, /* startId */ 0);
verify(mDevice).cancelPairing(); verify(mDevice).cancelBondProcess();
verify(mNm).cancel(mBluetoothPairingService.NOTIFICATION_ID); verify(mNm).cancel(mBluetoothPairingService.NOTIFICATION_ID);
} }

View File

@@ -84,18 +84,6 @@ public abstract class AbsBasePrivacySettingsPreference {
protected void verifyFinancedPreferenceControllers( protected void verifyFinancedPreferenceControllers(
List<AbstractPreferenceController> controllers) { List<AbstractPreferenceController> controllers) {
assertThat(controllers).isNotNull(); assertThat(controllers).isEmpty();
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);
} }
} }

View File

@@ -17,6 +17,7 @@
package com.android.settings.testutils; package com.android.settings.testutils;
import static android.provider.Settings.ACTION_BEDTIME_SETTINGS; 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; import static org.robolectric.Shadows.shadowOf;
@@ -25,6 +26,7 @@ import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.util.FeatureFlagUtils;
/** A helper class for installing bedtime settings activity. */ /** A helper class for installing bedtime settings activity. */
public final class BedtimeSettingsUtils { public final class BedtimeSettingsUtils {
@@ -35,6 +37,8 @@ public final class BedtimeSettingsUtils {
} }
public void installBedtimeSettings(String wellbeingPackage, boolean enabled) { 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) Intent bedtimeSettingsIntent = new Intent(ACTION_BEDTIME_SETTINGS)
.setPackage(wellbeingPackage); .setPackage(wellbeingPackage);
ResolveInfo bedtimeResolveInfo = new ResolveInfo(); ResolveInfo bedtimeResolveInfo = new ResolveInfo();

View File

@@ -1,2 +1,2 @@
# Additional reviewers for this and subdirectories. # We do not guard tests - everyone is welcomed to contribute to tests.
goldmanj@google.com per-file *.java=*