DO NOT MERGE ANYWHERE Vibrator: Allow priority vibrations in low-power mode for accessibility.
This is mainly for Wear devices that don't have speakers. Bug: 37543478 Bug: 37257715 Merged-In: Ia6dffa7e528886e7c84390dbb33b44f298c7afa4 Change-Id: Ia6dffa7e528886e7c84390dbb33b44f298c7afa4
This commit is contained in:
committed by
Chris Manton
parent
21caf4aee4
commit
79613777df
@@ -2520,6 +2520,10 @@
|
|||||||
<!-- How long history of previous vibrations should be kept for the dumpsys. -->
|
<!-- How long history of previous vibrations should be kept for the dumpsys. -->
|
||||||
<integer name="config_previousVibrationsDumpLimit">20</integer>
|
<integer name="config_previousVibrationsDumpLimit">20</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
|
<!-- Number of retries Cell Data should attempt for a given error code before
|
||||||
restarting the modem.
|
restarting the modem.
|
||||||
Error codes not listed will not lead to modem restarts.
|
Error codes not listed will not lead to modem restarts.
|
||||||
|
|||||||
@@ -1735,6 +1735,7 @@
|
|||||||
<java-symbol type="fraction" name="config_dimBehindFadeDuration" />
|
<java-symbol type="fraction" name="config_dimBehindFadeDuration" />
|
||||||
<java-symbol type="dimen" name="default_minimal_size_resizable_task" />
|
<java-symbol type="dimen" name="default_minimal_size_resizable_task" />
|
||||||
<java-symbol type="fraction" name="config_screenAutoBrightnessDozeScaleFactor" />
|
<java-symbol type="fraction" name="config_screenAutoBrightnessDozeScaleFactor" />
|
||||||
|
<java-symbol type="bool" name="config_allowPriorityVibrationsInLowPowerMode" />
|
||||||
<java-symbol type="fraction" name="config_autoBrightnessAdjustmentMaxGamma" />
|
<java-symbol type="fraction" name="config_autoBrightnessAdjustmentMaxGamma" />
|
||||||
<java-symbol type="fraction" name="config_autoBrightnessDarkHorizonThresholdFactor" />
|
<java-symbol type="fraction" name="config_autoBrightnessDarkHorizonThresholdFactor" />
|
||||||
<java-symbol type="integer" name="config_autoBrightnessAmbientLightHorizon"/>
|
<java-symbol type="integer" name="config_autoBrightnessAmbientLightHorizon"/>
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class VibratorService extends IVibratorService.Stub
|
|||||||
|
|
||||||
private int mCurVibUid = -1;
|
private int mCurVibUid = -1;
|
||||||
private boolean mLowPowerMode;
|
private boolean mLowPowerMode;
|
||||||
|
private boolean mAllowPriorityVibrationsInLowPowerMode;
|
||||||
private SettingsObserver mSettingObserver;
|
private SettingsObserver mSettingObserver;
|
||||||
|
|
||||||
native static boolean vibratorExists();
|
native static boolean vibratorExists();
|
||||||
@@ -215,6 +216,9 @@ public class VibratorService extends IVibratorService.Stub
|
|||||||
mPreviousVibrationsLimit = mContext.getResources().getInteger(
|
mPreviousVibrationsLimit = mContext.getResources().getInteger(
|
||||||
com.android.internal.R.integer.config_previousVibrationsDumpLimit);
|
com.android.internal.R.integer.config_previousVibrationsDumpLimit);
|
||||||
|
|
||||||
|
mAllowPriorityVibrationsInLowPowerMode = mContext.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_allowPriorityVibrationsInLowPowerMode);
|
||||||
|
|
||||||
mVibrations = new LinkedList<>();
|
mVibrations = new LinkedList<>();
|
||||||
mPreviousVibrations = new LinkedList<>();
|
mPreviousVibrations = new LinkedList<>();
|
||||||
|
|
||||||
@@ -447,8 +451,7 @@ public class VibratorService extends IVibratorService.Stub
|
|||||||
// Lock held on mVibrations
|
// Lock held on mVibrations
|
||||||
private void startVibrationLocked(final Vibration vib) {
|
private void startVibrationLocked(final Vibration vib) {
|
||||||
try {
|
try {
|
||||||
if (mLowPowerMode
|
if (!isAllowedToVibrate(vib)) {
|
||||||
&& vib.mUsageHint != AudioAttributes.USAGE_NOTIFICATION_RINGTONE) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,6 +488,23 @@ public class VibratorService extends IVibratorService.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isAllowedToVibrate(Vibration vib) {
|
||||||
|
if (mLowPowerMode) {
|
||||||
|
if (vib.mUsageHint == AudioAttributes.USAGE_NOTIFICATION_RINGTONE) {
|
||||||
|
return true;
|
||||||
|
} else if (mAllowPriorityVibrationsInLowPowerMode) {
|
||||||
|
if (vib.mUsageHint == AudioAttributes.USAGE_ALARM ||
|
||||||
|
vib.mUsageHint == AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY ||
|
||||||
|
vib.mUsageHint == AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean shouldVibrateForRingtone() {
|
private boolean shouldVibrateForRingtone() {
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||||
int ringerMode = audioManager.getRingerModeInternal();
|
int ringerMode = audioManager.getRingerModeInternal();
|
||||||
|
|||||||
Reference in New Issue
Block a user