Snap for 11603317 from 88feeec3c1 to 24Q3-release

Change-Id: I4f14cadaf26c7a37e03311a5740c1dc73ff8b07a
This commit is contained in:
Android Build Coastguard Worker
2024-03-20 23:21:41 +00:00
15 changed files with 224 additions and 298 deletions

View File

@@ -1236,8 +1236,10 @@
<string name="private_space_category_ways_to_unlock">Ways to unlock</string> <string name="private_space_category_ways_to_unlock">Ways to unlock</string>
<!-- Summary for one lock when device screen lock is used as private profile lock. [CHAR LIMIT=40] --> <!-- Summary for one lock when device screen lock is used as private profile lock. [CHAR LIMIT=40] -->
<string name="private_space_screen_lock_summary">Same as device screen lock</string> <string name="private_space_screen_lock_summary">Same as device screen lock</string>
<!-- Dialog message to choose a new lock for Private Space. [CHAR LIMIT=50] --> <!-- Dialog title to choose a new lock for Private Space. [CHAR LIMIT=50] -->
<string name="private_space_new_lock_title">Choose a new lock for private space?</string> <string name="private_space_new_lock_title">Choose a new lock for private space?</string>
<!-- Dialog message mentioning device PIN, pattern or password needs to be entered on the next screen. [CHAR LIMIT=NONE] -->
<string name="private_space_new_lock_message">You\ll need to enter your device PIN, pattern, or password on the next screen</string>
<!-- Title for the preference for auto lock private space and auto lock private space settings page. [CHAR LIMIT=50] --> <!-- Title for the preference for auto lock private space and auto lock private space settings page. [CHAR LIMIT=50] -->
<string name="private_space_auto_lock_title">Lock private space automatically</string> <string name="private_space_auto_lock_title">Lock private space automatically</string>
<!-- Description for private space auto lock settings page. [CHAR LIMIT=NONE] --> <!-- Description for private space auto lock settings page. [CHAR LIMIT=NONE] -->
@@ -1248,28 +1250,26 @@
<string name="private_space_auto_lock_after_inactivity">After 5 minutes of inactivity</string> <string name="private_space_auto_lock_after_inactivity">After 5 minutes of inactivity</string>
<!-- Configure auto lock: Value for auto lock configuration to never lock private space. [CHAR LIMIT=20] --> <!-- Configure auto lock: Value for auto lock configuration to never lock private space. [CHAR LIMIT=20] -->
<string name="private_space_auto_lock_never">Never</string> <string name="private_space_auto_lock_never">Never</string>
<!-- Title for the preference to hide Private Space. [CHAR LIMIT=60] --> <!-- Title for the settings preference and settings page for hide private space when locked setting. [CHAR LIMIT=60] -->
<string name="private_space_hide_title">Hide when locked</string> <string name="private_space_hide_page_title">Hide private space when it\'s locked</string>
<!-- Title for the hide Private Space setting. [CHAR LIMIT=60] -->
<string name="privatespace_hide_page_title">Hide private space when locked</string>
<!-- Description for hide Private Space settings page. [CHAR LIMIT=NONE] --> <!-- Description for hide Private Space settings page. [CHAR LIMIT=NONE] -->
<string name="privatespace_hide_page_summary">To stop other people knowing you have a private space on your device, you can hide it from your apps list</string> <string name="private_space_hide_page_summary">To stop other people knowing you have a private space on your device, you can hide it from your apps list</string>
<!-- Header in hide Private Space settings page to access Private Space when hidden. [CHAR LIMIT=60] --> <!-- Header in hide Private Space settings page to access Private Space when hidden. [CHAR LIMIT=60] -->
<string name="privatespace_access_header">Access private space when hidden</string> <string name="private_space_access_header">Access private space when hidden</string>
<!-- Text in hide Private Space settings page on how to search Private Space when hidden. [CHAR LIMIT=90] --> <!-- Text in hide Private Space settings page on how to search Private Space when hidden. [CHAR LIMIT=90] -->
<string name="privatespace_search_description">From your apps list, enter \"private space\" in the search bar</string> <string name="private_space_search_description">In the search bar, enter \"private space\"</string>
<!-- Text in hide Private Space settings page to tap on Private Space tile. [CHAR LIMIT=60] --> <!-- Text in hide Private Space settings page to tap on Private Space tile. [CHAR LIMIT=60] -->
<string name="privatespace_tap_tile_description">Tap the private space tile</string> <string name="private_space_tap_tile_description">Tap <b>Private space</b></string>
<!-- Text in hide Private Space settings page to Unlock Private Space. [CHAR LIMIT=60] --> <!-- Text in hide Private Space settings page to Unlock Private Space. [CHAR LIMIT=60] -->
<string name="privatespace_unlock_description">Unlock your private space</string> <string name="private_space_unlock_description">Unlock your private space</string>
<!-- Used to describe the off state of Private space hidden [CHAR LIMIT=30] --> <!-- Used to describe the off state of Private space hidden [CHAR LIMIT=30] -->
<string name="privatespace_hide_off_summary">Off</string> <string name="private_space_hide_off_summary">Off</string>
<!-- Used to describe the off state of Private space hidden [CHAR LIMIT=30] --> <!-- Used to describe the off state of Private space hidden [CHAR LIMIT=30] -->
<string name="privatespace_hide_on_summary">On</string> <string name="private_space_hide_on_summary">On</string>
<!-- Title for the dialog shown when Private space hidden setting is turned on. [CHAR LIMIT=60] --> <!-- Title for the dialog shown when Private space hidden setting is turned on. [CHAR LIMIT=60] -->
<string name="private_space_hide_dialog_title">Private space will hide when you lock it next</string> <string name="private_space_hide_dialog_title">Private space will hide the next time you lock it</string>
<!-- Text message in the dialog shown when Private space hidden setting is turned on. [CHAR LIMIT=90] --> <!-- Text message in the dialog shown when Private space hidden setting is turned on. [CHAR LIMIT=90] -->
<string name="private_space_hide_dialog_message">To access your space when its hidden, enter \“private space\” in the search bar on your apps list</string> <string name="private_space_hide_dialog_message">To access private space, enter \“private space\” in the search bar from your apps list.</string>
<!-- Label for the dialog shown when Private space hidden setting is turned on. [CHAR LIMIT=90] --> <!-- Label for the dialog shown when Private space hidden setting is turned on. [CHAR LIMIT=90] -->
<string name="private_space_hide_dialog_button">Got it</string> <string name="private_space_hide_dialog_button">Got it</string>
<!-- System category for the Private Space page. [CHAR LIMIT=30] --> <!-- System category for the Private Space page. [CHAR LIMIT=30] -->
@@ -2860,7 +2860,7 @@
<!-- Dark UI screen footer action text shown when the when Dark theme turns on/off automatically according to a user bedtime schedule. [CHAR LIMIT=NONE] --> <!-- Dark UI screen footer action text shown when the when Dark theme turns on/off automatically according to a user bedtime schedule. [CHAR LIMIT=NONE] -->
<string name="dark_ui_bedtime_footer_action">Bedtime mode settings</string> <string name="dark_ui_bedtime_footer_action">Bedtime mode settings</string>
<!-- Even Dimmer setting title. Allows device to reduce brightness even further than standard range. [CHAR LIMIT=NONE] --> <!-- Even Dimmer setting title. Allows device to reduce brightness even further than standard range. [CHAR LIMIT=NONE] -->
<string name="even_dimmer_display_title">Even Dimmer</string> <string name="even_dimmer_display_title">Even dimmer</string>
<!-- Even Dimmer setting summary. [CHAR LIMIT=NONE] --> <!-- Even Dimmer setting summary. [CHAR LIMIT=NONE] -->
<string name="even_dimmer_display_summary">Allow device to go dimmer than usual</string> <string name="even_dimmer_display_summary">Allow device to go dimmer than usual</string>
@@ -10555,7 +10555,7 @@
<string name="back_sensitivity_dialog_title">Back Sensitivity</string> <string name="back_sensitivity_dialog_title">Back Sensitivity</string>
<!-- Title for the screen to show all the gesture navigation settings [CHAR LIMIT=80] --> <!-- Title for the screen to show all the gesture navigation settings [CHAR LIMIT=80] -->
<string name="gesture_settings_activity_title">Gesture Navigation Sensitivity</string> <string name="gesture_settings_activity_title">Gesture Navigation</string>
<!-- Title for the screen to show all the 2- and 3-button navigation settings. [CHAR LIMIT=80] --> <!-- Title for the screen to show all the 2- and 3-button navigation settings. [CHAR LIMIT=80] -->
<string name="button_navigation_settings_activity_title">Button navigation</string> <string name="button_navigation_settings_activity_title">Button navigation</string>

View File

@@ -16,7 +16,7 @@
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto" xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/privatespace_hide_page_title"> android:title="@string/private_space_hide_page_title">
<com.android.settingslib.widget.IllustrationPreference <com.android.settingslib.widget.IllustrationPreference
android:key="privatespace_hide_video" android:key="privatespace_hide_video"
@@ -25,36 +25,36 @@
<com.android.settingslib.widget.MainSwitchPreference <com.android.settingslib.widget.MainSwitchPreference
android:key="hide_when_locked" android:key="hide_when_locked"
android:title="@string/privatespace_hide_page_title" android:title="@string/private_space_hide_page_title"
settings:controller="com.android.settings.privatespace.HidePrivateSpaceController"/> settings:controller="com.android.settings.privatespace.HidePrivateSpaceController"/>
<Preference <Preference
android:key="private_space_hidden" android:key="private_space_hidden"
android:summary="@string/privatespace_hide_page_summary" android:summary="@string/private_space_hide_page_summary"
android:selectable="false" android:selectable="false"
settings:searchable="false" /> settings:searchable="false" />
<PreferenceCategory <PreferenceCategory
android:title="@string/privatespace_access_header"> android:title="@string/private_space_access_header">
<Preference <Preference
android:key="search_when_locked_footer" android:key="search_when_locked_footer"
android:icon="@drawable/counter_1_24dp" android:icon="@drawable/counter_1_24dp"
android:title="@string/privatespace_search_description" android:title="@string/private_space_search_description"
android:selectable="false" android:selectable="false"
settings:searchable="false" /> settings:searchable="false" />
<Preference <Preference
android:key="tap_tile_footer" android:key="tap_tile_footer"
android:icon="@drawable/counter_2_24dp" android:icon="@drawable/counter_2_24dp"
android:title="@string/privatespace_tap_tile_description" android:title="@string/private_space_tap_tile_description"
android:selectable="false" android:selectable="false"
settings:searchable="false" /> settings:searchable="false" />
<Preference <Preference
android:key="unlock_profile_footer" android:key="unlock_profile_footer"
android:icon="@drawable/counter_3_24dp" android:icon="@drawable/counter_3_24dp"
android:title="@string/privatespace_unlock_description" android:title="@string/private_space_unlock_description"
android:selectable="false" android:selectable="false"
settings:searchable="false" /> settings:searchable="false" />

View File

@@ -52,7 +52,7 @@
<Preference <Preference
android:key="private_space_hidden" android:key="private_space_hidden"
android:title="@string/private_space_hide_title" android:title="@string/private_space_hide_page_title"
android:fragment="com.android.settings.privatespace.HidePrivateSpaceSettings" android:fragment="com.android.settings.privatespace.HidePrivateSpaceSettings"
settings:controller="com.android.settings.privatespace.HidePrivateSpaceSummaryController" settings:controller="com.android.settings.privatespace.HidePrivateSpaceSummaryController"
settings:searchable="false" /> settings:searchable="false" />

View File

@@ -1,155 +0,0 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.accessibility;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.text.BidiFormatter;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import com.android.settings.R;
import java.util.Locale;
/**
* Utility class for creating the dialog that asks users for explicit permission for an
* accessibility service to access user data before the service is enabled
*/
public class AccessibilityServiceWarning {
private static final View.OnTouchListener filterTouchListener = (View v, MotionEvent event) -> {
// Filter obscured touches by consuming them.
if (((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0)
|| ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_PARTIALLY_OBSCURED) != 0)) {
if (event.getAction() == MotionEvent.ACTION_UP) {
Toast.makeText(v.getContext(), R.string.touch_filtered_warning,
Toast.LENGTH_SHORT).show();
}
return true;
}
return false;
};
/**
* The interface to execute the uninstallation action.
*/
interface UninstallActionPerformer {
void uninstallPackage();
}
/**
* Returns a {@link Dialog} to be shown to confirm that they want to enable a service.
* @deprecated Use {@link com.android.internal.accessibility.dialog.AccessibilityServiceWarning}
*/
@Deprecated
public static Dialog createCapabilitiesDialog(@NonNull Context context,
@NonNull AccessibilityServiceInfo info, @NonNull View.OnClickListener listener,
@NonNull UninstallActionPerformer performer) {
final AlertDialog ad = new AlertDialog.Builder(context)
.setView(createEnableDialogContentView(context, info, listener, performer))
.create();
Window window = ad.getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.privateFlags |= SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
window.setAttributes(params);
ad.create();
ad.setCanceledOnTouchOutside(true);
return ad;
}
private static View createEnableDialogContentView(Context context,
@NonNull AccessibilityServiceInfo info, View.OnClickListener listener,
UninstallActionPerformer performer) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
View content = inflater.inflate(R.layout.enable_accessibility_service_dialog_content,
null);
final Drawable icon;
if (info.getResolveInfo().getIconResource() == 0) {
icon = ContextCompat.getDrawable(context, R.drawable.ic_accessibility_generic);
} else {
icon = info.getResolveInfo().loadIcon(context.getPackageManager());
}
ImageView permissionDialogIcon = content.findViewById(
R.id.permissionDialog_icon);
permissionDialogIcon.setImageDrawable(icon);
TextView permissionDialogTitle = content.findViewById(R.id.permissionDialog_title);
permissionDialogTitle.setText(context.getString(R.string.enable_service_title,
getServiceName(context, info)));
Button permissionAllowButton = content.findViewById(
R.id.permission_enable_allow_button);
Button permissionDenyButton = content.findViewById(
R.id.permission_enable_deny_button);
permissionAllowButton.setOnClickListener(listener);
permissionAllowButton.setOnTouchListener(filterTouchListener);
permissionDenyButton.setOnClickListener(listener);
final Button uninstallButton = content.findViewById(
R.id.permission_enable_uninstall_button);
// Shows an uninstall button to help users quickly remove the non-system App due to the
// required permissions.
if (!AccessibilityUtil.isSystemApp(info)) {
uninstallButton.setVisibility(View.VISIBLE);
uninstallButton.setOnClickListener(v -> performer.uninstallPackage());
}
return content;
}
/** Returns a {@link Dialog} to be shown to confirm that they want to disable a service. */
public static Dialog createDisableDialog(Context context,
AccessibilityServiceInfo info, DialogInterface.OnClickListener listener) {
CharSequence serviceName = getServiceName(context, info);
return new AlertDialog.Builder(context)
.setTitle(context.getString(R.string.disable_service_title, serviceName))
.setCancelable(true)
.setPositiveButton(R.string.accessibility_dialog_button_stop, listener)
.setNegativeButton(R.string.accessibility_dialog_button_cancel, listener)
.create();
}
// Get the service name and bidi wrap it to protect from bidi side effects.
private static CharSequence getServiceName(Context context, AccessibilityServiceInfo info) {
final Locale locale = context.getResources().getConfiguration().getLocales().get(0);
final CharSequence label =
info.getResolveInfo().loadLabel(context.getPackageManager());
return BidiFormatter.getInstance(locale).unicodeWrap(label);
}
}

View File

@@ -18,9 +18,7 @@ package com.android.settings.accessibility;
import android.accessibilityservice.AccessibilityServiceInfo; import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.view.View;
import com.android.settings.R;
import com.android.settingslib.accessibility.AccessibilityUtils; import com.android.settingslib.accessibility.AccessibilityUtils;
/** /**
@@ -52,26 +50,9 @@ public class InvisibleToggleAccessibilityServicePreferenceFragment extends
super.onToggleClicked(preference); super.onToggleClicked(preference);
boolean enabled = getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED) boolean enabled = getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED)
&& preference.isChecked(); && preference.isChecked();
AccessibilityUtils.setAccessibilityServiceState(getContext(), mComponentName, enabled); AccessibilityUtils.setAccessibilityServiceState(getContext(), mComponentName, enabled);
} }
/**
* {@inheritDoc}
*
* Enables accessibility service when user clicks permission allow button.
*/
@Override
void onDialogButtonFromShortcutToggleClicked(View view) {
super.onDialogButtonFromShortcutToggleClicked(view);
if (!android.view.accessibility.Flags.cleanupAccessibilityWarningDialog()) {
if (view.getId() == R.id.permission_enable_allow_button) {
AccessibilityUtils.setAccessibilityServiceState(getContext(), mComponentName,
true);
}
}
}
/** /**
* {@inheritDoc} * {@inheritDoc}
* *
@@ -80,9 +61,7 @@ public class InvisibleToggleAccessibilityServicePreferenceFragment extends
@Override @Override
void onAllowButtonFromShortcutToggleClicked() { void onAllowButtonFromShortcutToggleClicked() {
super.onAllowButtonFromShortcutToggleClicked(); super.onAllowButtonFromShortcutToggleClicked();
if (android.view.accessibility.Flags.cleanupAccessibilityWarningDialog()) { AccessibilityUtils.setAccessibilityServiceState(getContext(), mComponentName, true);
AccessibilityUtils.setAccessibilityServiceState(getContext(), mComponentName, true);
}
} }
/** /**

View File

@@ -32,6 +32,7 @@ import android.text.TextUtils;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.server.display.feature.flags.Flags;
import com.android.settings.R; import com.android.settings.R;
import com.android.settingslib.PrimarySwitchPreference; import com.android.settingslib.PrimarySwitchPreference;
import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -88,6 +89,15 @@ public class ReduceBrightColorsPreferenceController
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
// Successor to this feature is Even Dimmer
// found in display/EvenDimmerPreferenceController
// Only allow RBC if even dimmer is not possible on this device
if (Flags.evenDimmer() && mContext.getResources().getBoolean(
com.android.internal.R.bool.config_evenDimmerEnabled)) {
return UNSUPPORTED_ON_DEVICE;
}
return ColorDisplayManager.isReduceBrightColorsAvailable(mContext) ? AVAILABLE return ColorDisplayManager.isReduceBrightColorsAvailable(mContext) ? AVAILABLE
: UNSUPPORTED_ON_DEVICE; : UNSUPPORTED_ON_DEVICE;
} }

View File

@@ -21,6 +21,7 @@ import static com.android.settings.accessibility.AccessibilityStatsLogUtils.logA
import static com.android.settings.accessibility.PreferredShortcuts.retrieveUserShortcutType; import static com.android.settings.accessibility.PreferredShortcuts.retrieveUserShortcutType;
import android.accessibilityservice.AccessibilityServiceInfo; import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@@ -35,6 +36,7 @@ import android.content.pm.ResolveInfo;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemClock; import android.os.SystemClock;
import android.text.BidiFormatter;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
@@ -52,6 +54,7 @@ import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragm
import com.android.settingslib.accessibility.AccessibilityUtils; import com.android.settingslib.accessibility.AccessibilityUtils;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
/** Fragment for providing toggle bar and basic accessibility service setup. */ /** Fragment for providing toggle bar and basic accessibility service setup. */
@@ -158,69 +161,63 @@ public class ToggleAccessibilityServicePreferenceFragment extends
if (info == null) { if (info == null) {
return null; return null;
} }
if (android.view.accessibility.Flags.cleanupAccessibilityWarningDialog()) { mWarningDialog =
mWarningDialog = com.android.internal.accessibility.dialog.AccessibilityServiceWarning
com.android.internal.accessibility.dialog.AccessibilityServiceWarning .createAccessibilityServiceWarningDialog(getPrefContext(), info,
.createAccessibilityServiceWarningDialog(getPrefContext(), info, v -> onAllowButtonFromEnableToggleClicked(),
v -> onAllowButtonFromEnableToggleClicked(), v -> onDenyButtonFromEnableToggleClicked(),
v -> onDenyButtonFromEnableToggleClicked(), v -> onDialogButtonFromUninstallClicked());
v -> onDialogButtonFromUninstallClicked());
} else {
mWarningDialog = AccessibilityServiceWarning
.createCapabilitiesDialog(getPrefContext(), info,
this::onDialogButtonFromEnableToggleClicked,
this::onDialogButtonFromUninstallClicked);
}
return mWarningDialog; return mWarningDialog;
case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE: case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE:
if (info == null) { if (info == null) {
return null; return null;
} }
if (android.view.accessibility.Flags.cleanupAccessibilityWarningDialog()) { mWarningDialog =
mWarningDialog = com.android.internal.accessibility.dialog.AccessibilityServiceWarning
com.android.internal.accessibility.dialog.AccessibilityServiceWarning .createAccessibilityServiceWarningDialog(getPrefContext(), info,
.createAccessibilityServiceWarningDialog(getPrefContext(), info, v -> onAllowButtonFromShortcutToggleClicked(),
v -> onAllowButtonFromShortcutToggleClicked(), v -> onDenyButtonFromShortcutToggleClicked(),
v -> onDenyButtonFromShortcutToggleClicked(), v -> onDialogButtonFromUninstallClicked());
v -> onDialogButtonFromUninstallClicked());
} else {
mWarningDialog = AccessibilityServiceWarning
.createCapabilitiesDialog(getPrefContext(), info,
this::onDialogButtonFromShortcutToggleClicked,
this::onDialogButtonFromUninstallClicked);
}
return mWarningDialog; return mWarningDialog;
case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT: case DialogEnums.ENABLE_WARNING_FROM_SHORTCUT:
if (info == null) { if (info == null) {
return null; return null;
} }
if (android.view.accessibility.Flags.cleanupAccessibilityWarningDialog()) { mWarningDialog =
mWarningDialog = com.android.internal.accessibility.dialog.AccessibilityServiceWarning
com.android.internal.accessibility.dialog.AccessibilityServiceWarning .createAccessibilityServiceWarningDialog(getPrefContext(), info,
.createAccessibilityServiceWarningDialog(getPrefContext(), info, v -> onAllowButtonFromShortcutClicked(),
v -> onAllowButtonFromShortcutClicked(), v -> onDenyButtonFromShortcutClicked(),
v -> onDenyButtonFromShortcutClicked(), v -> onDialogButtonFromUninstallClicked());
v -> onDialogButtonFromUninstallClicked());
} else {
mWarningDialog = AccessibilityServiceWarning
.createCapabilitiesDialog(getPrefContext(), info,
this::onDialogButtonFromShortcutClicked,
this::onDialogButtonFromUninstallClicked);
}
return mWarningDialog; return mWarningDialog;
case DialogEnums.DISABLE_WARNING_FROM_TOGGLE: case DialogEnums.DISABLE_WARNING_FROM_TOGGLE:
if (info == null) { if (info == null) {
return null; return null;
} }
mWarningDialog = AccessibilityServiceWarning mWarningDialog = createDisableDialog(
.createDisableDialog(getPrefContext(), info, getPrefContext(), info, this::onDialogButtonFromDisableToggleClicked);
this::onDialogButtonFromDisableToggleClicked);
return mWarningDialog; return mWarningDialog;
default: default:
return super.onCreateDialog(dialogId); return super.onCreateDialog(dialogId);
} }
} }
/** Returns a {@link Dialog} to be shown to confirm that they want to disable a service. */
private static Dialog createDisableDialog(Context context,
AccessibilityServiceInfo info, DialogInterface.OnClickListener listener) {
final Locale locale = context.getResources().getConfiguration().getLocales().get(0);
final CharSequence label =
info.getResolveInfo().loadLabel(context.getPackageManager());
CharSequence serviceName = BidiFormatter.getInstance(locale).unicodeWrap(label);
return new AlertDialog.Builder(context)
.setTitle(context.getString(R.string.disable_service_title, serviceName))
.setCancelable(true)
.setPositiveButton(R.string.accessibility_dialog_button_stop, listener)
.setNegativeButton(R.string.accessibility_dialog_button_cancel, listener)
.create();
}
@Override @Override
public int getDialogMetricsCategory(int dialogId) { public int getDialogMetricsCategory(int dialogId) {
switch (dialogId) { switch (dialogId) {
@@ -333,13 +330,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends
final int shortcutTypes = retrieveUserShortcutType(getPrefContext(), final int shortcutTypes = retrieveUserShortcutType(getPrefContext(),
mComponentName.flattenToString(), getDefaultShortcutTypes()); mComponentName.flattenToString(), getDefaultShortcutTypes());
if (preference.isChecked()) { if (preference.isChecked()) {
final boolean isWarningRequired; final boolean isWarningRequired =
if (android.view.accessibility.Flags.cleanupAccessibilityWarningDialog()) { getPrefContext().getSystemService(AccessibilityManager.class)
isWarningRequired = getPrefContext().getSystemService(AccessibilityManager.class) .isAccessibilityServiceWarningRequired(getAccessibilityServiceInfo());
.isAccessibilityServiceWarningRequired(getAccessibilityServiceInfo());
} else {
isWarningRequired = !mToggleServiceSwitchPreference.isChecked();
}
if (isWarningRequired) { if (isWarningRequired) {
preference.setChecked(false); preference.setChecked(false);
showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE); showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE);
@@ -355,15 +348,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends
@Override @Override
public void onSettingsClicked(ShortcutPreference preference) { public void onSettingsClicked(ShortcutPreference preference) {
final boolean isWarningRequired; final boolean isWarningRequired =
if (android.view.accessibility.Flags.cleanupAccessibilityWarningDialog()) { getPrefContext().getSystemService(AccessibilityManager.class)
isWarningRequired = getPrefContext().getSystemService(AccessibilityManager.class) .isAccessibilityServiceWarningRequired(getAccessibilityServiceInfo());
.isAccessibilityServiceWarningRequired(getAccessibilityServiceInfo());
} else {
isWarningRequired = !(mShortcutPreference.isChecked()
|| mToggleServiceSwitchPreference.isChecked());
}
if (isWarningRequired) { if (isWarningRequired) {
showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_SHORTCUT); showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_SHORTCUT);
} else { } else {
@@ -537,17 +524,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
mWarningDialog.dismiss(); mWarningDialog.dismiss();
} }
void onDialogButtonFromShortcutClicked(View view) {
final int viewId = view.getId();
if (viewId == R.id.permission_enable_allow_button) {
onAllowButtonFromShortcutClicked();
} else if (viewId == R.id.permission_enable_deny_button) {
onDenyButtonFromShortcutClicked();
} else {
throw new IllegalArgumentException("Unexpected view id");
}
}
private void onAllowButtonFromShortcutClicked() { private void onAllowButtonFromShortcutClicked() {
mIsDialogShown.set(false); mIsDialogShown.set(false);
if (Flags.editShortcutsInFullScreen()) { if (Flags.editShortcutsInFullScreen()) {
@@ -576,13 +552,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends
mToggleServiceSwitchPreference.setChecked(false); mToggleServiceSwitchPreference.setChecked(false);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED,
/* disableService */ false); /* disableService */ false);
final boolean isWarningRequired; final boolean isWarningRequired =
if (android.view.accessibility.Flags.cleanupAccessibilityWarningDialog()) { getPrefContext().getSystemService(AccessibilityManager.class)
isWarningRequired = getPrefContext().getSystemService(AccessibilityManager.class) .isAccessibilityServiceWarningRequired(getAccessibilityServiceInfo());
.isAccessibilityServiceWarningRequired(getAccessibilityServiceInfo());
} else {
isWarningRequired = !mShortcutPreference.isChecked();
}
if (isWarningRequired) { if (isWarningRequired) {
showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_TOGGLE); showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_TOGGLE);
} else { } else {

View File

@@ -27,6 +27,8 @@ import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.PreferenceXmlParserUtils.MetadataFlag; import com.android.settings.core.PreferenceXmlParserUtils.MetadataFlag;
import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.core.AbstractPreferenceController;
@@ -93,6 +95,25 @@ public class PreferenceControllerListHelper {
return controllers; return controllers;
} }
/**
* Checks if the given PreferenceScreen will be empty due to all preferences being unavailable.
*
* @param xmlResId resource id of the PreferenceScreen to check
* @return {@code true} if none of the preferences in the given screen will appear
*/
public static boolean areAllPreferencesUnavailable(@NonNull Context context,
@NonNull PreferenceManager preferenceManager, @XmlRes int xmlResId) {
PreferenceScreen screen = preferenceManager.inflateFromResource(context, xmlResId,
/* rootPreferences= */ null);
List<BasePreferenceController> preferenceControllers =
getPreferenceControllersFromXml(context, xmlResId);
if (screen.getPreferenceCount() != preferenceControllers.size()) {
// There are some preferences without controllers, which will show regardless.
return false;
}
return preferenceControllers.stream().noneMatch(BasePreferenceController::isAvailable);
}
/** /**
* Return a sub list of {@link AbstractPreferenceController} to only contain controller that * Return a sub list of {@link AbstractPreferenceController} to only contain controller that
* doesn't exist in filter. * doesn't exist in filter.

View File

@@ -43,6 +43,8 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityGestureNavigationTutorial; import com.android.settings.accessibility.AccessibilityGestureNavigationTutorial;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerListHelper;
import com.android.settings.core.SubSettingLauncher; import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider; import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
@@ -147,14 +149,20 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
final PreferenceScreen screen = getPreferenceScreen(); final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll(); screen.removeAll();
screen.addPreference(mVideoPreference); screen.addPreference(mVideoPreference);
addPreferencesFromResource(getPreferenceScreenResId());
final List<BasePreferenceController> preferenceControllers = PreferenceControllerListHelper
.getPreferenceControllersFromXml(getContext(), getPreferenceScreenResId());
preferenceControllers.forEach(controller -> {
controller.updateState(findPreference(controller.getPreferenceKey()));
controller.displayPreference(screen);
});
final List<? extends CandidateInfo> candidateList = getCandidates(); final List<? extends CandidateInfo> candidateList = getCandidates();
if (candidateList == null) { if (candidateList == null) {
return; return;
} }
for (CandidateInfo info : candidateList) { for (CandidateInfo info : candidateList) {
SelectorWithWidgetPreference pref = SelectorWithWidgetPreference pref = new SelectorWithWidgetPreference(getPrefContext());
new SelectorWithWidgetPreference(getPrefContext());
bindPreference(pref, info.getKey(), info, defaultKey); bindPreference(pref, info.getKey(), info, defaultKey);
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey); bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
screen.addPreference(pref); screen.addPreference(pref);
@@ -176,8 +184,11 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
GestureNavigationSettingsFragment.GESTURE_NAVIGATION_SETTINGS))); GestureNavigationSettingsFragment.GESTURE_NAVIGATION_SETTINGS)));
} }
if (KEY_SYSTEM_NAV_2BUTTONS.equals(info.getKey()) || KEY_SYSTEM_NAV_3BUTTONS.equals( if ((KEY_SYSTEM_NAV_2BUTTONS.equals(info.getKey())
info.getKey())) { || KEY_SYSTEM_NAV_3BUTTONS.equals(info.getKey()))
// Don't add the settings button if that page will be blank.
&& !PreferenceControllerListHelper.areAllPreferencesUnavailable(
getContext(), getPreferenceManager(), R.xml.button_navigation_settings)) {
pref.setExtraWidgetOnClickListener((v) -> pref.setExtraWidgetOnClickListener((v) ->
new SubSettingLauncher(getContext()) new SubSettingLauncher(getContext())
.setDestination(ButtonNavigationSettingsFragment.class.getName()) .setDestination(ButtonNavigationSettingsFragment.class.getName())

View File

@@ -49,8 +49,8 @@ public final class HidePrivateSpaceSummaryController extends BasePreferenceContr
@Override @Override
public CharSequence getSummary() { public CharSequence getSummary() {
return isHidden() ? mContext.getString(R.string.privatespace_hide_on_summary) return isHidden() ? mContext.getString(R.string.private_space_hide_on_summary)
: mContext.getString(R.string.privatespace_hide_off_summary); : mContext.getString(R.string.private_space_hide_off_summary);
} }
private boolean isHidden() { private boolean isHidden() {

View File

@@ -192,7 +192,8 @@ public class UseOneLockControllerSwitch extends AbstractPreferenceController
return; return;
} }
new AlertDialog.Builder(mContext) new AlertDialog.Builder(mContext)
.setMessage(R.string.private_space_new_lock_title) .setTitle(R.string.private_space_new_lock_title)
.setMessage(R.string.private_space_new_lock_message)
.setPositiveButton( .setPositiveButton(
R.string.private_space_set_lock_label, R.string.private_space_set_lock_label,
(dialog, which) -> { (dialog, which) -> {

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2024 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="fake_title_key"
android:title="screen_title">
<Preference
android:key="key1"
android:title="title"
android:icon="@drawable/ic_android"
android:summary="summary1"
settings:controller="com.android.settings.core.UnavailablePreferenceController"/>
<Preference
android:key="key2"
android:title="title"
android:icon="@drawable/ic_android"
android:summary="summary2"
settings:controller="com.android.settings.core.UnavailablePreferenceController"/>
</PreferenceScreen>

View File

@@ -237,7 +237,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG)
public void enableService_warningRequired_showWarning() throws Throwable { public void enableService_warningRequired_showWarning() throws Throwable {
setupServiceWarningRequired(true); setupServiceWarningRequired(true);
mFragment.mToggleServiceSwitchPreference = mFragment.mToggleServiceSwitchPreference =
@@ -250,7 +249,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG)
public void enableService_warningNotRequired_dontShowWarning() throws Throwable { public void enableService_warningNotRequired_dontShowWarning() throws Throwable {
final AccessibilityServiceInfo info = setupServiceWarningRequired(false); final AccessibilityServiceInfo info = setupServiceWarningRequired(false);
mFragment.mToggleServiceSwitchPreference = mFragment.mToggleServiceSwitchPreference =
@@ -264,7 +262,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG)
public void toggleShortcutPreference_warningRequired_showWarning() throws Throwable { public void toggleShortcutPreference_warningRequired_showWarning() throws Throwable {
setupServiceWarningRequired(true); setupServiceWarningRequired(true);
mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */null); mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */null);
@@ -278,7 +275,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG)
public void toggleShortcutPreference_warningNotRequired_dontShowWarning() throws Throwable { public void toggleShortcutPreference_warningNotRequired_dontShowWarning() throws Throwable {
setupServiceWarningRequired(false); setupServiceWarningRequired(false);
mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */null); mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */null);
@@ -292,7 +288,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG)
public void clickShortcutSettingsPreference_warningRequired_showWarning() throws Throwable { public void clickShortcutSettingsPreference_warningRequired_showWarning() throws Throwable {
setupServiceWarningRequired(true); setupServiceWarningRequired(true);
mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */null); mFragment.mShortcutPreference = new ShortcutPreference(mContext, /* attrs= */null);
@@ -304,7 +299,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG)
@DisableFlags( @DisableFlags(
com.android.settings.accessibility.Flags.FLAG_EDIT_SHORTCUTS_IN_FULL_SCREEN) com.android.settings.accessibility.Flags.FLAG_EDIT_SHORTCUTS_IN_FULL_SCREEN)
public void clickShortcutSettingsPreference_warningNotRequired_dontShowWarning_showDialog() public void clickShortcutSettingsPreference_warningNotRequired_dontShowWarning_showDialog()
@@ -319,8 +313,7 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags({Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG, @EnableFlags(com.android.settings.accessibility.Flags.FLAG_EDIT_SHORTCUTS_IN_FULL_SCREEN)
com.android.settings.accessibility.Flags.FLAG_EDIT_SHORTCUTS_IN_FULL_SCREEN})
public void clickShortcutSettingsPreference_warningNotRequired_dontShowWarning_launchActivity() public void clickShortcutSettingsPreference_warningNotRequired_dontShowWarning_launchActivity()
throws Throwable { throws Throwable {
setupServiceWarningRequired(false); setupServiceWarningRequired(false);
@@ -365,7 +358,7 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags({Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG, Flags.FLAG_A11Y_QS_SHORTCUT}) @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_enableQsShortcut() public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_enableQsShortcut()
throws Throwable { throws Throwable {
PreferredShortcuts.clearPreferredShortcuts(mContext); PreferredShortcuts.clearPreferredShortcuts(mContext);
@@ -383,7 +376,7 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags({Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG, Flags.FLAG_A11Y_QS_SHORTCUT}) @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_enableSoftwareShortcut() public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_enableSoftwareShortcut()
throws Throwable { throws Throwable {
PreferredShortcuts.clearPreferredShortcuts(mContext); PreferredShortcuts.clearPreferredShortcuts(mContext);
@@ -401,7 +394,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG)
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_flagOff_enableSoftwareShortcut() public void toggleShortcutPreference_noUserPreferredShortcut_hasQsTile_flagOff_enableSoftwareShortcut()
throws Throwable { throws Throwable {
@@ -420,7 +412,6 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG)
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT) @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_flagOff_enableSoftwareShortcut() public void toggleShortcutPreference_noUserPreferredShortcut_noQsTile_flagOff_enableSoftwareShortcut()
throws Throwable { throws Throwable {
@@ -439,7 +430,7 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags({Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG, Flags.FLAG_A11Y_QS_SHORTCUT}) @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void toggleShortcutPreference_userPreferVolumeKeysShortcut_noQsTile_enableVolumeKeysShortcut() public void toggleShortcutPreference_userPreferVolumeKeysShortcut_noQsTile_enableVolumeKeysShortcut()
throws Throwable { throws Throwable {
setupServiceWarningRequired(false); setupServiceWarningRequired(false);
@@ -462,7 +453,7 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
} }
@Test @Test
@EnableFlags({Flags.FLAG_CLEANUP_ACCESSIBILITY_WARNING_DIALOG, Flags.FLAG_A11Y_QS_SHORTCUT}) @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void toggleShortcutPreference_userPreferVolumeKeysShortcut_hasQsTile_enableVolumeKeysShortcut() public void toggleShortcutPreference_userPreferVolumeKeysShortcut_hasQsTile_enableVolumeKeysShortcut()
throws Throwable { throws Throwable {
setupServiceWarningRequired(false); setupServiceWarningRequired(false);

View File

@@ -20,6 +20,8 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.Context; import android.content.Context;
import androidx.preference.PreferenceManager;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.slices.FakePreferenceController; import com.android.settings.slices.FakePreferenceController;
import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.core.AbstractPreferenceController;
@@ -38,10 +40,12 @@ import java.util.List;
public class PreferenceControllerListHelperTest { public class PreferenceControllerListHelperTest {
private Context mContext; private Context mContext;
private PreferenceManager mPreferenceManager;
@Before @Before
public void setUp() { public void setUp() {
mContext = RuntimeEnvironment.application; mContext = RuntimeEnvironment.application;
mPreferenceManager = new PreferenceManager(mContext);
} }
@Test @Test
@@ -68,6 +72,30 @@ public class PreferenceControllerListHelperTest {
assertThat(controllers.get(0)).isInstanceOf(FakePreferenceController.class); assertThat(controllers.get(0)).isInstanceOf(FakePreferenceController.class);
} }
@Test
@Config(qualifiers = "mcc999")
public void areAllPreferencesUnavailable_allAvailable() {
// All preferences have controllers indicating they are available.
assertThat(PreferenceControllerListHelper.areAllPreferencesUnavailable(mContext,
mPreferenceManager, R.xml.location_settings)).isFalse();
}
@Test
@Config(qualifiers = "mcc997")
public void areAllPreferencesUnavailable_allUnavailable() {
// All preferences have controllers indicating they are unavailable. (note the qualifier)
assertThat(PreferenceControllerListHelper.areAllPreferencesUnavailable(mContext,
mPreferenceManager, R.xml.location_settings)).isTrue();
}
@Test
@Config(qualifiers = "mcc999")
public void areAllPreferencesUnavailable_noControllersShouldAssumeAvailable() {
// None of the preferences have controllers, so they are assumed available.
assertThat(PreferenceControllerListHelper.areAllPreferencesUnavailable(mContext,
mPreferenceManager, R.xml.display_settings)).isFalse();
}
@Test @Test
public void filterControllers_noFilter_shouldReturnSameList() { public void filterControllers_noFilter_shouldReturnSameList() {
final List<BasePreferenceController> controllers = new ArrayList<>(); final List<BasePreferenceController> controllers = new ArrayList<>();

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2024 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.core;
import android.content.Context;
public class UnavailablePreferenceController extends BasePreferenceController {
public UnavailablePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
public int getAvailabilityStatus() {
return UNSUPPORTED_ON_DEVICE;
}
}