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

Commit a28a41d9 authored by Ahmad Khalil's avatar Ahmad Khalil
Browse files

Add reason to start charging vibration

We're adding a reason to the hardware feedback vibration when charging starts, to make it easier to identify in the dumpsys logs.

Bug: 316076290
Test: N/A
Change-Id: I8d3be23480ba53a56a22209b346deaed4edbd87a
parent 03823b64
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -958,7 +958,8 @@ public class Notifier {
            final boolean vibrate = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                    Settings.Secure.CHARGING_VIBRATION_ENABLED, 1, userId) != 0;
            if (vibrate) {
                mVibrator.vibrate(CHARGING_VIBRATION_EFFECT,
                mVibrator.vibrate(Process.SYSTEM_UID, mContext.getOpPackageName(),
                        CHARGING_VIBRATION_EFFECT, /* reason= */ "Charging started",
                        HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES);
            }

+8 −5
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

import android.content.Context;
@@ -113,7 +114,8 @@ public class NotifierTest {
        mTestExecutor.simulateAsyncExecutionOfLastCommand();

        // THEN the device vibrates once
        verify(mVibrator, times(1)).vibrate(any(), any(VibrationAttributes.class));
        verify(mVibrator, times(1)).vibrate(anyInt(), any(), any(), any(),
                any(VibrationAttributes.class));
    }

    @Test
@@ -129,7 +131,7 @@ public class NotifierTest {
        mTestExecutor.simulateAsyncExecutionOfLastCommand();

        // THEN the device doesn't vibrate
        verify(mVibrator, never()).vibrate(any(), any(VibrationAttributes.class));
        verifyZeroInteractions(mVibrator);
    }

    @Test
@@ -145,14 +147,15 @@ public class NotifierTest {
        mTestExecutor.simulateAsyncExecutionOfLastCommand();

        // THEN the device vibrates once
        verify(mVibrator, times(1)).vibrate(any(), any(VibrationAttributes.class));
        verify(mVibrator, times(1)).vibrate(anyInt(), any(), any(), any(),
                any(VibrationAttributes.class));
    }

    @Test
    public void testVibrateDisabled_wirelessCharging() {
        createNotifier();

        // GIVEN the charging vibration is disabeld
        // GIVEN the charging vibration is disabled
        enableChargingVibration(false);

        // WHEN wireless charging starts
@@ -161,7 +164,7 @@ public class NotifierTest {
        mTestExecutor.simulateAsyncExecutionOfLastCommand();

        // THEN the device doesn't vibrate
        verify(mVibrator, never()).vibrate(any(), any(VibrationAttributes.class));
        verifyZeroInteractions(mVibrator);
    }

    @Test