Merge "Vibrator: Have Always-On Check DND/LowPower Modes"
This commit is contained in:
@@ -24,7 +24,8 @@ interface IVibratorService
|
||||
{
|
||||
boolean hasVibrator();
|
||||
boolean hasAmplitudeControl();
|
||||
boolean setAlwaysOnEffect(int id, in VibrationEffect effect, in AudioAttributes attributes);
|
||||
boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId, in VibrationEffect effect,
|
||||
in AudioAttributes attributes);
|
||||
void vibrate(int uid, String opPkg, in VibrationEffect effect, in AudioAttributes attributes,
|
||||
String reason, IBinder token);
|
||||
void cancelVibrate(IBinder token);
|
||||
|
||||
@@ -70,13 +70,14 @@ public class SystemVibrator extends Vibrator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setAlwaysOnEffect(int id, VibrationEffect effect, AudioAttributes attributes) {
|
||||
public boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId, VibrationEffect effect,
|
||||
AudioAttributes attributes) {
|
||||
if (mService == null) {
|
||||
Log.w(TAG, "Failed to set always-on effect; no vibrator service.");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return mService.setAlwaysOnEffect(id, effect, attributes);
|
||||
return mService.setAlwaysOnEffect(uid, opPkg, alwaysOnId, effect, attributes);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed to set always-on effect.", e);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public abstract class Vibrator {
|
||||
/**
|
||||
* Configure an always-on haptics effect.
|
||||
*
|
||||
* @param id The board-specific always-on ID to configure.
|
||||
* @param alwaysOnId The board-specific always-on ID to configure.
|
||||
* @param effect Vibration effect to assign to always-on id. Passing null will disable it.
|
||||
* @param attributes {@link AudioAttributes} corresponding to the vibration. For example,
|
||||
* specify {@link AudioAttributes#USAGE_ALARM} for alarm vibrations or
|
||||
@@ -164,8 +164,17 @@ public abstract class Vibrator {
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.VIBRATE_ALWAYS_ON)
|
||||
public boolean setAlwaysOnEffect(int id, @Nullable VibrationEffect effect,
|
||||
@Nullable AudioAttributes attributes) {
|
||||
public boolean setAlwaysOnEffect(int alwaysOnId, @Nullable VibrationEffect effect,
|
||||
@Nullable AudioAttributes attributes) {
|
||||
return setAlwaysOnEffect(Process.myUid(), mPackageName, alwaysOnId, effect, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.VIBRATE_ALWAYS_ON)
|
||||
public boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId,
|
||||
@Nullable VibrationEffect effect, @Nullable AudioAttributes attributes) {
|
||||
Log.w(TAG, "Always-on effects aren't supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user