Merge "use an observer for the default sound" into nyc-mr1-dev

This commit is contained in:
Chris Wren
2016-06-27 15:08:01 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 4 deletions

View File

@@ -305,6 +305,7 @@ public class NotificationManagerService extends SystemService {
private RankingHandler mRankingHandler;
private long mLastOverRateLogTime;
private float mMaxPackageEnqueueRate = DEFAULT_MAX_NOTIFICATION_ENQUEUE_RATE;
private String mSystemNotificationSound;
private static class Archive {
final int mBufferSize;
@@ -817,6 +818,8 @@ public class NotificationManagerService extends SystemService {
private final class SettingsObserver extends ContentObserver {
private final Uri NOTIFICATION_LIGHT_PULSE_URI
= Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE);
private final Uri NOTIFICATION_SOUND_URI
= Settings.System.getUriFor(Settings.System.NOTIFICATION_SOUND);
private final Uri NOTIFICATION_RATE_LIMIT_URI
= Settings.Global.getUriFor(Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE);
@@ -828,6 +831,8 @@ public class NotificationManagerService extends SystemService {
ContentResolver resolver = getContext().getContentResolver();
resolver.registerContentObserver(NOTIFICATION_LIGHT_PULSE_URI,
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(NOTIFICATION_SOUND_URI,
false, this, UserHandle.USER_ALL);
resolver.registerContentObserver(NOTIFICATION_RATE_LIMIT_URI,
false, this, UserHandle.USER_ALL);
update(null);
@@ -851,6 +856,10 @@ public class NotificationManagerService extends SystemService {
mMaxPackageEnqueueRate = Settings.Global.getFloat(resolver,
Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE, mMaxPackageEnqueueRate);
}
if (uri == null || NOTIFICATION_SOUND_URI.equals(uri)) {
mSystemNotificationSound = Settings.System.getString(resolver,
Settings.System.NOTIFICATION_SOUND);
}
}
}
@@ -903,6 +912,11 @@ public class NotificationManagerService extends SystemService {
mHandler = handler;
}
@VisibleForTesting
void setSystemNotificationSound(String systemNotificationSound) {
mSystemNotificationSound = systemNotificationSound;
}
@Override
public void onStart() {
Resources resources = getContext().getResources();
@@ -2869,9 +2883,7 @@ public class NotificationManagerService extends SystemService {
soundUri = Settings.System.DEFAULT_NOTIFICATION_URI;
// check to see if the default notification sound is silent
ContentResolver resolver = getContext().getContentResolver();
hasValidSound = Settings.System.getString(resolver,
Settings.System.NOTIFICATION_SOUND) != null;
hasValidSound = mSystemNotificationSound != null;
} else if (notification.sound != null) {
soundUri = notification.sound;
hasValidSound = (soundUri != null);

View File

@@ -33,7 +33,6 @@ import java.util.concurrent.TimeUnit;
/**
* Unit tests for FakeSettingsProvider.
*/
@Suppress
public class FakeSettingsProviderTest extends AndroidTestCase {
private MockContentResolver mCr;

View File

@@ -76,6 +76,7 @@ public class BuzzBeepBlinkTest extends AndroidTestCase {
mService.setVibrator(mVibrator);
mService.setSystemReady(true);
mService.setHandler(mHandler);
mService.setSystemNotificationSound("beep!");
}
//