Snap for 12702769 from 851bf18783 to 25Q1-release

Change-Id: I76b4be2604f387b8fcfaa6ea76a044e4612990d3
This commit is contained in:
Android Build Coastguard Worker
2024-11-23 02:17:04 +00:00
34 changed files with 164 additions and 96 deletions

View File

@@ -0,0 +1,9 @@
package: "com.android.settings.keyboard"
container: "system"
flag {
name: "keyboard_layout_picker_activity_enabled"
namespace: "input"
description: "This flag enables or disables exposed page of keyboard layout picker"
bug: "345399212"
}

View File

@@ -20,7 +20,8 @@
<com.android.settingslib.widget.TopIntroPreference
android:key="accessibility_button_intro"
android:persistent="false"
android:title="@string/accessibility_button_intro_text" />
android:title="@string/accessibility_button_intro_text"
settings:searchable="false" />
<com.android.settingslib.widget.IllustrationPreference
android:key="accessibility_button_preview"

View File

@@ -110,10 +110,6 @@ public class RestrictedPreferenceHelper {
*/
public List<AccessibilityActivityPreference> createAccessibilityActivityPreferenceList(
List<AccessibilityShortcutInfo> installedShortcuts) {
final Set<ComponentName> enabledServices =
AccessibilityUtils.getEnabledServicesFromSettings(mContext);
final List<String> permittedServices = mDpm.getPermittedAccessibilityServices(
UserHandle.myUserId());
final int installedShortcutsSize = installedShortcuts.size();
final List<AccessibilityActivityPreference> preferenceList = new ArrayList<>(
@@ -124,17 +120,12 @@ public class RestrictedPreferenceHelper {
final ActivityInfo activityInfo = info.getActivityInfo();
final ComponentName componentName = info.getComponentName();
final boolean serviceEnabled = enabledServices.contains(componentName);
AccessibilityActivityPreference preference = new AccessibilityActivityPreference(
mContext, componentName.getPackageName(), activityInfo.applicationInfo.uid,
info);
if (Flags.neverRestrictAccessibilityActivity()) {
// Accessibility Activities do not have elevated privileges so restricting
// them based on ECM or device admin does not give any value.
preference.setEnabled(true);
} else {
setRestrictedPreferenceEnabled(preference, permittedServices, serviceEnabled);
}
preferenceList.add(preference);
}
return preferenceList;

View File

@@ -270,7 +270,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
R.integer.config_biometrics_header_scroll_duration);
layoutView.adjustScrollableHeaderHeight(
headerScrollView, mShouldShowLottie);
layoutView.headerVerticalScrolling(headerScrollView, headerScrollDuration);
layoutView.headerVerticalScrolling(headerScrollView, headerScrollDuration,
mIsAccessibilityEnabled);
}
}
}
@@ -547,6 +548,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
}
private void updateTitleAndDescriptionForUdfps() {
final UdfpsEnrollEnrollingView layoutView = (UdfpsEnrollEnrollingView) getLayout();
final boolean shouldSetFocusOnDescription = Flags.enrollLayoutTruncateImprovement()
&& mIsAccessibilityEnabled;
switch (getCurrentStage()) {
case STAGE_CENTER:
setHeaderText(R.string.security_settings_fingerprint_enroll_repeat_title);
@@ -560,6 +564,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
);
configureEnrollmentStage(R.raw.udfps_center_hint_lottie);
}
if (shouldSetFocusOnDescription) {
layoutView.setFocusOnDescription();
}
break;
case STAGE_GUIDED:
@@ -574,6 +582,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
// TODO(b/228100413) Could customize guided lottie animation
configureEnrollmentStage(R.raw.udfps_center_hint_lottie);
}
if (shouldSetFocusOnDescription) {
layoutView.setFocusOnDescription();
}
break;
case STAGE_FINGERTIP:
setHeaderText(R.string.security_settings_udfps_enroll_fingertip_title);
@@ -584,6 +596,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
);
configureEnrollmentStage(R.raw.udfps_tip_hint_lottie);
}
if (shouldSetFocusOnDescription) {
layoutView.setFocusOnDescription();
}
break;
case STAGE_LEFT_EDGE:
setHeaderText(R.string.security_settings_udfps_enroll_left_edge_title);
@@ -601,6 +617,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
setDescriptionText(R.string.security_settings_udfps_enroll_edge_message);
}
}
if (shouldSetFocusOnDescription) {
layoutView.setFocusOnDescription();
}
break;
case STAGE_RIGHT_EDGE:
setHeaderText(R.string.security_settings_udfps_enroll_right_edge_title);
@@ -619,6 +639,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
setDescriptionText(R.string.security_settings_udfps_enroll_edge_message);
}
}
if (shouldSetFocusOnDescription) {
layoutView.setFocusOnDescription();
}
break;
case STAGE_UNKNOWN:

View File

@@ -25,6 +25,7 @@ import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.os.Handler;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
@@ -44,6 +45,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.LayoutRes;
@@ -200,7 +202,26 @@ public class UdfpsEnrollEnrollingView extends GlifLayout {
return footerBarMinHeight;
}
void headerVerticalScrolling(ScrollView headerScrollView, long duration) {
void setFocusOnDescription() {
final ScrollView headerScrollView = findViewById(R.id.sud_header_scroll_view);
final TextView descriptionView = getDescriptionTextView();
if (descriptionView != null && !descriptionView.getText().isEmpty()) {
descriptionView.post(
() -> {
Rect scrollBounds = new Rect();
headerScrollView.getHitRect(scrollBounds);
boolean isVisible = descriptionView.getLocalVisibleRect(scrollBounds);
if (!isVisible) {
descriptionView.setFocusable(true);
descriptionView.setFocusableInTouchMode(true);
descriptionView.requestFocus();
}
});
}
}
void headerVerticalScrolling(ScrollView headerScrollView, long duration,
boolean isAccessibilityEnabled) {
headerScrollView.post(new Runnable() {
@Override
public void run() {
@@ -216,11 +237,21 @@ public class UdfpsEnrollEnrollingView extends GlifLayout {
@Override
public void onAnimationEnd(@NonNull Animator animation) {
mHeaderScrollAnimator.removeAllListeners();
headerScrollView.post(new Runnable() {
@Override
public void run() {
mHeaderScrollAnimator.removeAllListeners();
mHeaderScrollAnimator.reverse();
if (isAccessibilityEnabled) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!mHeaderScrollAnimator.isRunning()) {
setFocusOnDescription();
}
}
}, duration + 200);
}
}
});
}
@@ -320,6 +351,19 @@ public class UdfpsEnrollEnrollingView extends GlifLayout {
R.id.udfps_enroll_animation_fp_view);
fingerprintView.setPadding(0, -layoutLottieAnimationPadding,
0, layoutLottieAnimationPadding);
// TODO(b/260970216) Instead of hiding the description text view, we should
// make the header view scrollable if the text is too long.
// If description text view has overlap with udfps progress view, hide it.
if (!Flags.enrollLayoutTruncateImprovement()) {
final View descView = getDescriptionTextView();
getViewTreeObserver().addOnDrawListener(() -> {
if (descView.getVisibility() == View.VISIBLE
&& hasOverlap(descView, mUdfpsEnrollView)) {
descView.setVisibility(View.GONE);
}
});
}
}
private void setOnHoverListener() {

View File

@@ -44,9 +44,9 @@ import java.util.Arrays;
import java.util.Comparator;
/**
* Utilities of keyboard settings
* Utilities of input peripherals settings
*/
public class NewKeyboardSettingsUtils {
public class InputPeripheralsSettingsUtils {
static final String EXTRA_TITLE = "keyboard_layout_picker_title";
static final String EXTRA_USER_ID = "user_id";

View File

@@ -308,7 +308,7 @@ public class KeyboardLayoutDialogFragment extends InstrumentedDialogFragment
public Keyboards loadInBackground() {
Keyboards keyboards = new Keyboards();
InputManager im = (InputManager)getContext().getSystemService(Context.INPUT_SERVICE);
if (mInputDeviceIdentifier == null || NewKeyboardSettingsUtils.getInputDevice(
if (mInputDeviceIdentifier == null || InputPeripheralsSettingsUtils.getInputDevice(
im, mInputDeviceIdentifier) == null) {
keyboards.keyboardLayouts.add(null); // default layout
keyboards.current = 0;

View File

@@ -68,11 +68,13 @@ public class KeyboardLayoutPickerController extends BasePreferenceController imp
public void onStart() {
mIm.registerInputDeviceListener(this, null);
if (mInputDeviceIdentifier == null
|| NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
|| InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier)
== null) {
return;
}
mInputDeviceId =
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier).getId();
InputPeripheralsSettingsUtils.getInputDevice(mIm,
mInputDeviceIdentifier).getId();
updateCheckedState();
}

View File

@@ -46,7 +46,7 @@ public class KeyboardLayoutPickerFragment extends DashboardFragment {
final InputDeviceIdentifier inputDeviceIdentifier = getActivity().getIntent().
getParcelableExtra(EXTRA_INPUT_DEVICE_IDENTIFIER);
final InputManager im = context.getSystemService(InputManager.class);
if (NewKeyboardSettingsUtils.getInputDevice(im, inputDeviceIdentifier) == null) {
if (InputPeripheralsSettingsUtils.getInputDevice(im, inputDeviceIdentifier) == null) {
return;
}
use(KeyboardLayoutPickerController.class).initialize(this /*parent*/,

View File

@@ -40,7 +40,7 @@ import com.android.settings.Utils;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.inputmethod.NewKeyboardSettingsUtils.KeyboardInfo;
import com.android.settings.inputmethod.InputPeripheralsSettingsUtils.KeyboardInfo;
import java.util.ArrayList;
import java.util.Collections;
@@ -117,14 +117,15 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
return;
}
mInputDeviceIdentifier =
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
arguments.getParcelable(
InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
InputDeviceIdentifier.class);
if (mInputDeviceIdentifier == null) {
Log.e(TAG, "The inputDeviceIdentifier should not be null");
return;
}
InputDevice inputDevice =
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
if (inputDevice == null) {
Log.e(TAG, "inputDevice is null");
return;
@@ -138,7 +139,7 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
super.onStart();
mIm.registerInputDeviceListener(this, null);
InputDevice inputDevice =
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
if (inputDevice == null) {
Log.e(TAG, "Unable to start: input device is null");
getActivity().finish();
@@ -161,7 +162,7 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
}
private void updateCheckedState() {
if (NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
if (InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
return;
}
@@ -207,9 +208,9 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
private void mapLanguageWithLayout(InputMethodInfo info, InputMethodSubtype subtype) {
CharSequence subtypeLabel = getSubtypeLabel(mContext, info, subtype);
KeyboardLayout[] keyboardLayouts =
NewKeyboardSettingsUtils.getKeyboardLayouts(
InputPeripheralsSettingsUtils.getKeyboardLayouts(
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
KeyboardLayoutSelectionResult result = NewKeyboardSettingsUtils.getKeyboardLayout(
KeyboardLayoutSelectionResult result = InputPeripheralsSettingsUtils.getKeyboardLayout(
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
if (result.getLayoutDescriptor() != null) {
for (int i = 0; i < keyboardLayouts.length; i++) {
@@ -316,13 +317,14 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
InputMethodSubtype inputMethodSubtype) {
Bundle arguments = new Bundle();
arguments.putParcelable(
NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER, inputDeviceIdentifier);
InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
inputDeviceIdentifier);
arguments.putParcelable(
NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_INFO, inputMethodInfo);
InputPeripheralsSettingsUtils.EXTRA_INPUT_METHOD_INFO, inputMethodInfo);
arguments.putParcelable(
NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE, inputMethodSubtype);
arguments.putInt(NewKeyboardSettingsUtils.EXTRA_USER_ID, userId);
arguments.putCharSequence(NewKeyboardSettingsUtils.EXTRA_TITLE, subtypeLabel);
InputPeripheralsSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE, inputMethodSubtype);
arguments.putInt(InputPeripheralsSettingsUtils.EXTRA_USER_ID, userId);
arguments.putCharSequence(InputPeripheralsSettingsUtils.EXTRA_TITLE, subtypeLabel);
new SubSettingLauncher(mContext)
.setSourceMetricsCategory(getMetricsCategory())
.setDestination(NewKeyboardLayoutPickerFragment.class.getName())

View File

@@ -48,9 +48,9 @@ public class NewKeyboardLayoutPickerContent extends DashboardFragment {
InputManager im = getContext().getSystemService(InputManager.class);
InputDeviceIdentifier identifier =
getArguments().getParcelable(
NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
if (identifier == null
|| NewKeyboardSettingsUtils.getInputDevice(im, identifier) == null) {
|| InputPeripheralsSettingsUtils.getInputDevice(im, identifier) == null) {
getActivity().finish();
return;
}

View File

@@ -73,19 +73,21 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
public void initialize(Fragment parent) {
mParent = parent;
Bundle arguments = parent.getArguments();
mTitle = arguments.getCharSequence(NewKeyboardSettingsUtils.EXTRA_TITLE);
mUserId = arguments.getInt(NewKeyboardSettingsUtils.EXTRA_USER_ID);
mTitle = arguments.getCharSequence(InputPeripheralsSettingsUtils.EXTRA_TITLE);
mUserId = arguments.getInt(InputPeripheralsSettingsUtils.EXTRA_USER_ID);
mInputDeviceIdentifier =
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
arguments.getParcelable(
InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
mInputMethodInfo =
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_INFO);
arguments.getParcelable(InputPeripheralsSettingsUtils.EXTRA_INPUT_METHOD_INFO);
mInputMethodSubtype =
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE);
arguments.getParcelable(
InputPeripheralsSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE);
mLayout = getSelectedLayoutLabel();
mFinalSelectedLayout = mLayout;
mKeyboardLayouts = mIm.getKeyboardLayoutListForInputDevice(
mInputDeviceIdentifier, mUserId, mInputMethodInfo, mInputMethodSubtype);
NewKeyboardSettingsUtils.sortKeyboardLayoutsByLabel(mKeyboardLayouts);
InputPeripheralsSettingsUtils.sortKeyboardLayoutsByLabel(mKeyboardLayouts);
parent.getActivity().setTitle(mTitle);
}
@@ -93,11 +95,13 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
public void onStart() {
mIm.registerInputDeviceListener(this, null);
if (mInputDeviceIdentifier == null
|| NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
|| InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier)
== null) {
return;
}
mInputDeviceId =
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier).getId();
InputPeripheralsSettingsUtils.getInputDevice(mIm,
mInputDeviceIdentifier).getId();
}
@Override
@@ -202,9 +206,9 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
private String getSelectedLayoutLabel() {
String label = mContext.getString(R.string.keyboard_default_layout);
KeyboardLayoutSelectionResult result = NewKeyboardSettingsUtils.getKeyboardLayout(
KeyboardLayoutSelectionResult result = InputPeripheralsSettingsUtils.getKeyboardLayout(
mIm, mUserId, mInputDeviceIdentifier, mInputMethodInfo, mInputMethodSubtype);
KeyboardLayout[] keyboardLayouts = NewKeyboardSettingsUtils.getKeyboardLayouts(
KeyboardLayout[] keyboardLayouts = InputPeripheralsSettingsUtils.getKeyboardLayouts(
mIm, mUserId, mInputDeviceIdentifier, mInputMethodInfo, mInputMethodSubtype);
if (result.getLayoutDescriptor() != null) {
for (KeyboardLayout keyboardLayout : keyboardLayouts) {

View File

@@ -317,7 +317,7 @@ public final class PhysicalKeyboardFragment extends DashboardFragment
final Preference pref = new Preference(getPrefContext());
pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
String currentLayout =
NewKeyboardSettingsUtils.getSelectedKeyboardLayoutLabelForUser(context,
InputPeripheralsSettingsUtils.getSelectedKeyboardLayoutLabelForUser(context,
UserHandle.myUserId(), hardKeyboardDeviceInfo.mDeviceIdentifier);
if (currentLayout != null) {
pref.setSummary(currentLayout);
@@ -369,7 +369,7 @@ public final class PhysicalKeyboardFragment extends DashboardFragment
private void showEnabledLocalesKeyboardLayoutList(InputDeviceIdentifier inputDeviceIdentifier) {
Bundle arguments = new Bundle();
arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
arguments.putParcelable(InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
inputDeviceIdentifier);
new SubSettingLauncher(getContext())
.setSourceMetricsCategory(getMetricsCategory())

View File

@@ -16,8 +16,8 @@
package com.android.settings.inputmethod;
import static com.android.settings.inputmethod.NewKeyboardSettingsUtils.isMouse;
import static com.android.settings.inputmethod.NewKeyboardSettingsUtils.isTouchpad;
import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isMouse;
import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isTouchpad;
import android.app.settings.SettingsEnums;
import android.content.Context;

View File

@@ -16,8 +16,8 @@
package com.android.settings.inputmethod;
import static com.android.settings.inputmethod.NewKeyboardSettingsUtils.isMouse;
import static com.android.settings.inputmethod.NewKeyboardSettingsUtils.isTouchpad;
import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isMouse;
import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isTouchpad;
import android.app.settings.SettingsEnums;
import android.content.Context;

View File

@@ -32,8 +32,8 @@ public class PointerTouchpadPreferenceController extends BasePreferenceControlle
@Override
public int getAvailabilityStatus() {
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
boolean isMouse = NewKeyboardSettingsUtils.isMouse();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
boolean isMouse = InputPeripheralsSettingsUtils.isMouse();
return (isTouchpad || isMouse) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
}

View File

@@ -74,7 +74,7 @@ public class TouchGesturesButtonPreferenceController extends BasePreferenceContr
@Override
public int getAvailabilityStatus() {
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
return isTouchpad ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -16,7 +16,7 @@
package com.android.settings.inputmethod;
import static com.android.settings.inputmethod.NewKeyboardSettingsUtils.isTouchpad;
import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isTouchpad;
import android.app.settings.SettingsEnums;
import android.content.Context;

View File

@@ -65,7 +65,7 @@ public class TouchpadThreeFingerTapPreferenceController extends BasePreferenceCo
@Override
public int getAvailabilityStatus() {
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
return (InputSettings.isTouchpadThreeFingerTapShortcutFeatureFlagEnabled() && isTouchpad)
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -49,7 +49,7 @@ public class TrackpadBottomPreferenceController extends TogglePreferenceControll
@Override
public int getAvailabilityStatus() {
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
return isTouchpad ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -49,7 +49,7 @@ public class TrackpadReverseScrollingPreferenceController extends TogglePreferen
@Override
public int getAvailabilityStatus() {
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
return isTouchpad ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -43,7 +43,7 @@ public class TrackpadSettings extends DashboardFragment {
public void onCreate(@NonNull Bundle icicle) {
super.onCreate(icicle);
getPreferenceScreen().setTitle(
NewKeyboardSettingsUtils.getTouchpadAndMouseTitleTitleResId());
InputPeripheralsSettingsUtils.getTouchpadAndMouseTitleTitleResId());
}
@Override
@@ -67,7 +67,7 @@ public class TrackpadSettings extends DashboardFragment {
protected boolean isPageSearchEnabled(Context context) {
return FeatureFlagUtils
.isEnabled(context, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD)
&& NewKeyboardSettingsUtils.isTouchpad();
&& InputPeripheralsSettingsUtils.isTouchpad();
}
};
}

View File

@@ -77,17 +77,17 @@ public class TrackpadSettingsController extends BasePreferenceController
return;
}
mPreference.setVisible(isAvailable());
mPreference.setTitle(NewKeyboardSettingsUtils.getTouchpadAndMouseTitleTitleResId());
mPreference.setTitle(InputPeripheralsSettingsUtils.getTouchpadAndMouseTitleTitleResId());
}
@Override
public int getAvailabilityStatus() {
boolean isFeatureOn = FeatureFlagUtils
.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD);
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
boolean isPointerCustomizationEnabled =
android.view.flags.Flags.enableVectorCursorA11ySettings();
boolean isMouse = NewKeyboardSettingsUtils.isMouse();
boolean isMouse = InputPeripheralsSettingsUtils.isMouse();
return (isFeatureOn && isTouchpad) || (isPointerCustomizationEnabled && isMouse) ? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -49,7 +49,7 @@ public class TrackpadTapDraggingPreferenceController extends TogglePreferenceCon
@Override
public int getAvailabilityStatus() {
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
return (InputSettings.isTouchpadTapDraggingFeatureFlagEnabled() && isTouchpad)
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -49,7 +49,7 @@ public class TrackpadTapToClickPreferenceController extends TogglePreferenceCont
@Override
public int getAvailabilityStatus() {
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
return isTouchpad ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -59,7 +59,7 @@ public class TrackpadTouchGestureSettings extends DashboardFragment {
.isEnabled(
context,
FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD_GESTURE)
&& NewKeyboardSettingsUtils.isTouchpad();
&& InputPeripheralsSettingsUtils.isTouchpad();
}
};
}

View File

@@ -31,7 +31,7 @@ public class TrackpadTouchGestureSettingsController extends BasePreferenceContro
public int getAvailabilityStatus() {
boolean isFeatureOn = FeatureFlagUtils
.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD_GESTURE);
boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
return (isFeatureOn && isTouchpad) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
}

View File

@@ -125,7 +125,7 @@ public class CellularSecurityPreferenceController extends BasePreferenceControll
return super.handlePreferenceTreeClick(preference);
}
boolean isSafetyCenterSupported = isSafetyCenterSupported();
if (isSafetyCenterSupported) {
if (isSafetyCenterSupported && areNotificationsEnabled()) {
Intent safetyCenterIntent = new Intent(Intent.ACTION_SAFETY_CENTER);
safetyCenterIntent.putExtra(SafetyCenterManager.EXTRA_SAFETY_SOURCES_GROUP_ID,
"AndroidCellularNetworkSecuritySources");

View File

@@ -36,6 +36,7 @@ public class UserCapabilities {
boolean mIsAdmin;
boolean mIsGuest;
boolean mIsEphemeral;
boolean mUserSwitchingUiEnabled;
boolean mUserSwitcherEnabled;
boolean mCanAddGuest;
boolean mDisallowAddUser;
@@ -68,7 +69,8 @@ public class UserCapabilities {
caps.mCanAddRestrictedProfile =
offerRestricted && !dpm.isDeviceManaged() && userManager.isUserTypeEnabled(
UserManager.USER_TYPE_FULL_RESTRICTED);
caps.mUserSwitchingUiEnabled = context.getResources().getBoolean(
com.android.internal.R.bool.config_allowChangeUserSwitcherEnabled);
caps.updateAddUserCapabilities(context);
return caps;
}
@@ -134,6 +136,7 @@ public class UserCapabilities {
", mEnforcedAdmin=" + mEnforcedAdmin +
", mDisallowSwitchUser=" + mDisallowSwitchUser +
", mDisallowAddUserSetByAdmin=" + mDisallowAddUserSetByAdmin +
", mUserSwitchingUiEnabled=" + mUserSwitchingUiEnabled +
", mUserSwitcherEnabled=" + mUserSwitcherEnabled +
'}';
}

View File

@@ -354,6 +354,8 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
mGrantAdminPref.setChecked(mUserInfo.isAdmin());
mSwitchUserPref.setVisible(mUserCaps.mUserSwitchingUiEnabled);
mSwitchUserPref.setTitle(
context.getString(com.android.settingslib.R.string.user_switch_to_user,
mUserInfo.name));

View File

@@ -287,7 +287,7 @@ public class UserSettings extends SettingsPreferenceFragment
final SettingsActivity activity = (SettingsActivity) getActivity();
final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
switchBar.setTitle(getContext().getString(R.string.multiple_users_main_switch_title));
if (!mUserCaps.mIsGuest) {
if (!mUserCaps.mIsGuest && mUserCaps.mUserSwitchingUiEnabled) {
switchBar.show();
} else {
switchBar.hide();

View File

@@ -31,7 +31,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
@@ -141,27 +140,10 @@ public class RestrictedPreferenceHelperTest {
assertThat(preference.getKey()).isEqualTo(key);
}
@Test
@EnableFlags(value = {android.security.Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS,
android.permission.flags.Flags.FLAG_ENHANCED_CONFIRMATION_MODE_APIS_ENABLED})
@DisableFlags(Flags.FLAG_NEVER_RESTRICT_ACCESSIBILITY_ACTIVITY)
public void createAccessibilityActivityPreference_ecmRestricted_prefIsEcmRestricted() {
setMockAccessibilityShortcutInfo(mShortcutInfo);
ShadowRestrictedLockUtilsInternal.setEcmRestrictedPkgs(PACKAGE_NAME);
final List<AccessibilityActivityPreference> preferenceList =
mHelper.createAccessibilityActivityPreferenceList(List.of(mShortcutInfo));
assertThat(preferenceList).hasSize(1);
final RestrictedPreference preference = preferenceList.get(0);
assertThat(preference.isDisabledByEcm()).isTrue();
}
@Test
@EnableFlags(value = {
android.security.Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS,
android.permission.flags.Flags.FLAG_ENHANCED_CONFIRMATION_MODE_APIS_ENABLED,
Flags.FLAG_NEVER_RESTRICT_ACCESSIBILITY_ACTIVITY,
})
public void createAccessibilityActivityPreference_ecmRestricted_prefIsNotEcmRestricted() {
setMockAccessibilityShortcutInfo(mShortcutInfo);

View File

@@ -72,7 +72,7 @@ public class TrackpadSettingsControllerTest {
InputDevice.SOURCE_TOUCHPAD);
ShadowInputDevice.addDevice(deviceId, device);
String expectedTitle = mContext.getString(
NewKeyboardSettingsUtils.getTouchpadAndMouseTitleTitleResId());
InputPeripheralsSettingsUtils.getTouchpadAndMouseTitleTitleResId());
mController.updateState(mPreference);

View File

@@ -152,6 +152,10 @@ public final class CellularSecurityPreferenceControllerTest {
public void handlePreferenceTreeClick_safetyCenterSupported_shouldRedirectToSafetyCenter() {
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
doReturn(true).when(mTelephonyManager).isNullCipherNotificationsEnabled();
doReturn(true).when(mTelephonyManager)
.isCellularIdentifierDisclosureNotificationsEnabled();
doReturn(true).when(mTelephonyManager).isNullCipherAndIntegrityPreferenceEnabled();
boolean prefHandled = mController.handlePreferenceTreeClick(mPreference);
assertThat(prefHandled).isTrue();