Skip to content
Snippets Groups Projects
Commit 995bd864 authored by Lais Andrade's avatar Lais Andrade
Browse files

Create VibrationThread only after binder calling ID cleared

The creation of the VibrationThread does some setup for the WakeLock
that the thread must hold, which should only be executed after the
Binder calling ID has been cleared.

The necessary checks for this operation are already done by the method
enforceUpdateAppOpsStatsPermission, so the VibratorManagerService should
be able to setup the thread wakelock at that stage.

Fix: 180324695
Test: manual
Change-Id: I2f203fc4c7ba78687e9159af93b3d1acd9c826c9
parent 43bf4611
No related branches found
No related tags found
No related merge requests found
......@@ -352,10 +352,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub {
return;
}
VibrationThread vibThread = new VibrationThread(vib, mVibrators, mWakeLock,
mBatteryStatsService, mVibrationCallbacks);
ignoreStatus = shouldIgnoreVibrationForCurrentLocked(vibThread);
ignoreStatus = shouldIgnoreVibrationForCurrentLocked(vib);
if (ignoreStatus != null) {
endVibrationLocked(vib, ignoreStatus);
return;
......@@ -366,7 +363,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub {
if (mCurrentVibration != null) {
mCurrentVibration.cancel();
}
Vibration.Status status = startVibrationLocked(vibThread);
Vibration.Status status = startVibrationLocked(vib);
if (status != Vibration.Status.RUNNING) {
endVibrationLocked(vib, status);
}
......@@ -491,19 +488,19 @@ public class VibratorManagerService extends IVibratorManagerService.Stub {
}
@GuardedBy("mLock")
private Vibration.Status startVibrationLocked(VibrationThread vibThread) {
private Vibration.Status startVibrationLocked(Vibration vib) {
Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "startVibrationLocked");
try {
Vibration vib = vibThread.getVibration();
vib.updateEffect(mVibrationScaler.scale(vib.getEffect(), vib.attrs.getUsage()));
boolean inputDevicesAvailable = mInputDeviceDelegate.vibrateIfAvailable(
vib.uid, vib.opPkg, vib.getEffect(), vib.reason, vib.attrs);
if (inputDevicesAvailable) {
return Vibration.Status.FORWARDED_TO_INPUT_DEVICES;
}
VibrationThread vibThread = new VibrationThread(vib, mVibrators, mWakeLock,
mBatteryStatsService, mVibrationCallbacks);
if (mCurrentVibration == null) {
return startVibrationThreadLocked(vibThread);
}
......@@ -595,8 +592,8 @@ public class VibratorManagerService extends IVibratorManagerService.Stub {
*/
@GuardedBy("mLock")
@Nullable
private Vibration.Status shouldIgnoreVibrationForCurrentLocked(VibrationThread vibThread) {
if (vibThread.getVibration().isRepeating()) {
private Vibration.Status shouldIgnoreVibrationForCurrentLocked(Vibration vibration) {
if (vibration.isRepeating()) {
// Repeating vibrations always take precedence.
return null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment