Extract Vibrator implementation from interface.

Moved the core logic of Vibrator into SystemVibrator, potentially
allowing for the creation of other Vibrator subclasses.

Fixed several places where we were creating new Vibrator
instances unnecessarily instead of getting it from the Context.

It is safe to make Vibrator abstract because its constructor
was hidden from the SDK so it was not possible to subclass it.

Bug: 6334179
Change-Id: I18ece6544c26a7efb2d5099f8346a10aef8a5e18
This commit is contained in:
Jeff Brown
2012-04-13 01:55:38 -07:00
parent 069c4f3f0c
commit c2346134bb
11 changed files with 133 additions and 88 deletions

View File

@@ -100,7 +100,7 @@ public class NotificationManagerService extends INotificationManager.Stub
private int mDisabledNotifications;
private NotificationRecord mVibrateNotification;
private Vibrator mVibrator = new Vibrator();
private Vibrator mVibrator;
// for enabling and disabling notification pulse behavior
private boolean mScreenOn = true;
@@ -398,6 +398,7 @@ public class NotificationManagerService extends INotificationManager.Stub
{
super();
mContext = context;
mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
mAm = ActivityManagerNative.getDefault();
mSound = new NotificationPlayer(TAG);
mSound.setUsesWakeLock(context);