Merge "Vibrator: Allow priority vibrations in low-power mode for accessibility." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ac36c42a86
@@ -2536,6 +2536,10 @@
|
|||||||
<!-- The default vibration strength, must be between 1 and 255 inclusive. -->
|
<!-- The default vibration strength, must be between 1 and 255 inclusive. -->
|
||||||
<integer name="config_defaultVibrationAmplitude">255</integer>
|
<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
|
<!-- 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.
|
||||||
|
|||||||
@@ -1809,6 +1809,7 @@
|
|||||||
<java-symbol type="dimen" name="default_minimal_size_pip_resizable_task" />
|
<java-symbol type="dimen" name="default_minimal_size_pip_resizable_task" />
|
||||||
<java-symbol type="dimen" name="task_height_of_minimized_mode" />
|
<java-symbol type="dimen" name="task_height_of_minimized_mode" />
|
||||||
<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="integer" name="config_autoBrightnessAmbientLightHorizon"/>
|
<java-symbol type="integer" name="config_autoBrightnessAmbientLightHorizon"/>
|
||||||
<java-symbol type="integer" name="config_autoBrightnessBrighteningLightDebounce"/>
|
<java-symbol type="integer" name="config_autoBrightnessBrighteningLightDebounce"/>
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ public class VibratorService extends IVibratorService.Stub
|
|||||||
|
|
||||||
private final LinkedList<VibrationInfo> mPreviousVibrations;
|
private final LinkedList<VibrationInfo> mPreviousVibrations;
|
||||||
private final int mPreviousVibrationsLimit;
|
private final int mPreviousVibrationsLimit;
|
||||||
|
private final boolean mAllowPriorityVibrationsInLowPowerMode;
|
||||||
private final boolean mSupportsAmplitudeControl;
|
private final boolean mSupportsAmplitudeControl;
|
||||||
private final int mDefaultVibrationAmplitude;
|
private final int mDefaultVibrationAmplitude;
|
||||||
private final VibrationEffect[] mFallbackEffects;
|
private final VibrationEffect[] mFallbackEffects;
|
||||||
@@ -213,6 +214,9 @@ public class VibratorService extends IVibratorService.Stub
|
|||||||
mDefaultVibrationAmplitude = mContext.getResources().getInteger(
|
mDefaultVibrationAmplitude = mContext.getResources().getInteger(
|
||||||
com.android.internal.R.integer.config_defaultVibrationAmplitude);
|
com.android.internal.R.integer.config_defaultVibrationAmplitude);
|
||||||
|
|
||||||
|
mAllowPriorityVibrationsInLowPowerMode = mContext.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_allowPriorityVibrationsInLowPowerMode);
|
||||||
|
|
||||||
mPreviousVibrations = new LinkedList<>();
|
mPreviousVibrations = new LinkedList<>();
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
@@ -456,7 +460,7 @@ public class VibratorService extends IVibratorService.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startVibrationLocked(final Vibration vib) {
|
private void startVibrationLocked(final Vibration vib) {
|
||||||
if (mLowPowerMode && vib.mUsageHint != AudioAttributes.USAGE_NOTIFICATION_RINGTONE) {
|
if (!isAllowedToVibrate(vib)) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.e(TAG, "Vibrate ignored, low power mode");
|
Slog.e(TAG, "Vibrate ignored, low power mode");
|
||||||
}
|
}
|
||||||
@@ -505,6 +509,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() {
|
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