Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28d9495a authored by Ahmad Khalil's avatar Ahmad Khalil Committed by Automerger Merge Worker
Browse files

Merge "Add accessibility usage to screen OFF usage allowlist." into udc-dev...

Merge "Add accessibility usage to screen OFF usage allowlist." into udc-dev am: 32758be6 am: 1f4ae348

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22627464



Change-Id: Ib473a37fa7114d9919a16141310828bc6bb2a4a1
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a9dc8c61 1f4ae348
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ final class VibrationSettings {
    private static final Set<Integer> SYSTEM_VIBRATION_SCREEN_OFF_USAGE_ALLOWLIST = new HashSet<>(
            Arrays.asList(
                    USAGE_TOUCH,
                    USAGE_ACCESSIBILITY,
                    USAGE_PHYSICAL_EMULATION,
                    USAGE_HARDWARE_FEEDBACK));

+27 −9
Original line number Diff line number Diff line
@@ -648,13 +648,19 @@ public class VibrationSettingsTest {
    }

    @Test
    public void shouldCancelVibrationOnScreenOff_withUidZero_returnsFalseForTouchAndHardware() {
    public void shouldCancelVibrationOnScreenOff_withUidZero_returnsFalseForUsagesInAllowlist() {
        long vibrateStartTime = 100;
        mockGoToSleep(vibrateStartTime + 10, PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN);

        Set<Integer> expectedAllowedVibrations = new HashSet<>(Arrays.asList(
                USAGE_TOUCH,
                USAGE_ACCESSIBILITY,
                USAGE_PHYSICAL_EMULATION,
                USAGE_HARDWARE_FEEDBACK
        ));

        for (int usage : ALL_USAGES) {
            if (usage == USAGE_TOUCH || usage == USAGE_HARDWARE_FEEDBACK
                    || usage == USAGE_PHYSICAL_EMULATION) {
            if (expectedAllowedVibrations.contains(usage)) {
                assertFalse(mVibrationSettings.shouldCancelVibrationOnScreenOff(
                        createCallerInfo(/* uid= */ 0, "", usage), vibrateStartTime));
            } else {
@@ -665,13 +671,19 @@ public class VibrationSettingsTest {
    }

    @Test
    public void shouldCancelVibrationOnScreenOff_withSystemUid_returnsFalseForTouchAndHardware() {
    public void shouldCancelVibrationOnScreenOff_withSystemUid__returnsFalseForUsagesInAllowlist() {
        long vibrateStartTime = 100;
        mockGoToSleep(vibrateStartTime + 10, PowerManager.GO_TO_SLEEP_REASON_DEVICE_FOLD);

        Set<Integer> expectedAllowedVibrations = new HashSet<>(Arrays.asList(
                USAGE_TOUCH,
                USAGE_ACCESSIBILITY,
                USAGE_PHYSICAL_EMULATION,
                USAGE_HARDWARE_FEEDBACK
        ));

        for (int usage : ALL_USAGES) {
            if (usage == USAGE_TOUCH || usage == USAGE_HARDWARE_FEEDBACK
                    || usage == USAGE_PHYSICAL_EMULATION) {
            if (expectedAllowedVibrations.contains(usage)) {
                assertFalse(mVibrationSettings.shouldCancelVibrationOnScreenOff(
                        createCallerInfo(Process.SYSTEM_UID, "", usage), vibrateStartTime));
            } else {
@@ -682,13 +694,19 @@ public class VibrationSettingsTest {
    }

    @Test
    public void shouldCancelVibrationOnScreenOff_withSysUiPkg_returnsFalseForTouchAndHardware() {
    public void shouldCancelVibrationOnScreenOff_withSysUiPkg_returnsFalseForUsagesInAllowlist() {
        long vibrateStartTime = 100;
        mockGoToSleep(vibrateStartTime + 10, PowerManager.GO_TO_SLEEP_REASON_HDMI);

        Set<Integer> expectedAllowedVibrations = new HashSet<>(Arrays.asList(
                USAGE_TOUCH,
                USAGE_ACCESSIBILITY,
                USAGE_PHYSICAL_EMULATION,
                USAGE_HARDWARE_FEEDBACK
        ));

        for (int usage : ALL_USAGES) {
            if (usage == USAGE_TOUCH || usage == USAGE_HARDWARE_FEEDBACK
                    || usage == USAGE_PHYSICAL_EMULATION) {
            if (expectedAllowedVibrations.contains(usage)) {
                assertFalse(mVibrationSettings.shouldCancelVibrationOnScreenOff(
                        createCallerInfo(UID, SYSUI_PACKAGE_NAME, usage), vibrateStartTime));
            } else {