Loading core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2580,6 +2580,10 @@ <!-- The default vibration strength, must be between 1 and 255 inclusive. --> <integer name="config_defaultVibrationAmplitude">255</integer> <!-- If the device should still vibrate even in low power mode, for certain priority vibrations (e.g. accessibility, alarms). This is mainly for Wear devices that don't have speakers. --> <bool name="config_allowPriorityVibrationsInLowPowerMode">false</bool> <!-- Number of retries Cell Data should attempt for a given error code before restarting the modem. Error codes not listed will not lead to modem restarts. Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1815,6 +1815,7 @@ <java-symbol type="dimen" name="default_minimal_size_pip_resizable_task" /> <java-symbol type="dimen" name="task_height_of_minimized_mode" /> <java-symbol type="fraction" name="config_screenAutoBrightnessDozeScaleFactor" /> <java-symbol type="bool" name="config_allowPriorityVibrationsInLowPowerMode" /> <java-symbol type="fraction" name="config_autoBrightnessAdjustmentMaxGamma" /> <java-symbol type="integer" name="config_autoBrightnessAmbientLightHorizon"/> <java-symbol type="integer" name="config_autoBrightnessBrighteningLightDebounce"/> Loading services/core/java/com/android/server/VibratorService.java +25 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public class VibratorService extends IVibratorService.Stub private final LinkedList<VibrationInfo> mPreviousVibrations; private final int mPreviousVibrationsLimit; private final boolean mAllowPriorityVibrationsInLowPowerMode; private final boolean mSupportsAmplitudeControl; private final int mDefaultVibrationAmplitude; private final VibrationEffect[] mFallbackEffects; Loading Loading @@ -213,6 +214,9 @@ public class VibratorService extends IVibratorService.Stub mDefaultVibrationAmplitude = mContext.getResources().getInteger( com.android.internal.R.integer.config_defaultVibrationAmplitude); mAllowPriorityVibrationsInLowPowerMode = mContext.getResources().getBoolean( com.android.internal.R.bool.config_allowPriorityVibrationsInLowPowerMode); mPreviousVibrations = new LinkedList<>(); IntentFilter filter = new IntentFilter(); Loading Loading @@ -461,7 +465,7 @@ public class VibratorService extends IVibratorService.Stub } private void startVibrationLocked(final Vibration vib) { if (mLowPowerMode && vib.mUsageHint != AudioAttributes.USAGE_NOTIFICATION_RINGTONE) { if (!isAllowedToVibrate(vib)) { if (DEBUG) { Slog.e(TAG, "Vibrate ignored, low power mode"); } Loading Loading @@ -510,6 +514,26 @@ public class VibratorService extends IVibratorService.Stub } } private boolean isAllowedToVibrate(Vibration vib) { if (!mLowPowerMode) { return true; } if (vib.mUsageHint == AudioAttributes.USAGE_NOTIFICATION_RINGTONE) { return true; } if (!mAllowPriorityVibrationsInLowPowerMode) { return false; } if (vib.mUsageHint == AudioAttributes.USAGE_ALARM || vib.mUsageHint == AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY || vib.mUsageHint == AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST) { return true; } return false; } private boolean shouldVibrateForRingtone() { AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); int ringerMode = audioManager.getRingerModeInternal(); Loading Loading
core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2580,6 +2580,10 @@ <!-- The default vibration strength, must be between 1 and 255 inclusive. --> <integer name="config_defaultVibrationAmplitude">255</integer> <!-- If the device should still vibrate even in low power mode, for certain priority vibrations (e.g. accessibility, alarms). This is mainly for Wear devices that don't have speakers. --> <bool name="config_allowPriorityVibrationsInLowPowerMode">false</bool> <!-- Number of retries Cell Data should attempt for a given error code before restarting the modem. Error codes not listed will not lead to modem restarts. Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1815,6 +1815,7 @@ <java-symbol type="dimen" name="default_minimal_size_pip_resizable_task" /> <java-symbol type="dimen" name="task_height_of_minimized_mode" /> <java-symbol type="fraction" name="config_screenAutoBrightnessDozeScaleFactor" /> <java-symbol type="bool" name="config_allowPriorityVibrationsInLowPowerMode" /> <java-symbol type="fraction" name="config_autoBrightnessAdjustmentMaxGamma" /> <java-symbol type="integer" name="config_autoBrightnessAmbientLightHorizon"/> <java-symbol type="integer" name="config_autoBrightnessBrighteningLightDebounce"/> Loading
services/core/java/com/android/server/VibratorService.java +25 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public class VibratorService extends IVibratorService.Stub private final LinkedList<VibrationInfo> mPreviousVibrations; private final int mPreviousVibrationsLimit; private final boolean mAllowPriorityVibrationsInLowPowerMode; private final boolean mSupportsAmplitudeControl; private final int mDefaultVibrationAmplitude; private final VibrationEffect[] mFallbackEffects; Loading Loading @@ -213,6 +214,9 @@ public class VibratorService extends IVibratorService.Stub mDefaultVibrationAmplitude = mContext.getResources().getInteger( com.android.internal.R.integer.config_defaultVibrationAmplitude); mAllowPriorityVibrationsInLowPowerMode = mContext.getResources().getBoolean( com.android.internal.R.bool.config_allowPriorityVibrationsInLowPowerMode); mPreviousVibrations = new LinkedList<>(); IntentFilter filter = new IntentFilter(); Loading Loading @@ -461,7 +465,7 @@ public class VibratorService extends IVibratorService.Stub } private void startVibrationLocked(final Vibration vib) { if (mLowPowerMode && vib.mUsageHint != AudioAttributes.USAGE_NOTIFICATION_RINGTONE) { if (!isAllowedToVibrate(vib)) { if (DEBUG) { Slog.e(TAG, "Vibrate ignored, low power mode"); } Loading Loading @@ -510,6 +514,26 @@ public class VibratorService extends IVibratorService.Stub } } private boolean isAllowedToVibrate(Vibration vib) { if (!mLowPowerMode) { return true; } if (vib.mUsageHint == AudioAttributes.USAGE_NOTIFICATION_RINGTONE) { return true; } if (!mAllowPriorityVibrationsInLowPowerMode) { return false; } if (vib.mUsageHint == AudioAttributes.USAGE_ALARM || vib.mUsageHint == AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY || vib.mUsageHint == AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST) { return true; } return false; } private boolean shouldVibrateForRingtone() { AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); int ringerMode = audioManager.getRingerModeInternal(); Loading