Remove more dead audio service code
Hit a snag in remote volume changes. Trying off this round of
removal so I can work on fixing remote volume handling in a
separate CL.
Change-Id: I49b1ba4b75d770ba7c77da081755f3210a9e9483
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index 67065ba..ecdbb5e 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -23,6 +23,7 @@
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -88,6 +89,7 @@
private KeyguardManager mKeyguardManager;
private IAudioService mAudioService;
+ private ContentResolver mContentResolver;
private MediaSessionRecord mPrioritySession;
private int mCurrentUserId = -1;
@@ -115,6 +117,7 @@
mKeyguardManager =
(KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE);
mAudioService = getAudioService();
+ mContentResolver = getContext().getContentResolver();
}
private IAudioService getAudioService() {
@@ -381,8 +384,7 @@
return false;
}
if (compName != null) {
- final String enabledNotifListeners = Settings.Secure.getStringForUser(
- getContext().getContentResolver(),
+ final String enabledNotifListeners = Settings.Secure.getStringForUser(mContentResolver,
Settings.Secure.ENABLED_NOTIFICATION_LISTENERS,
userId);
if (enabledNotifListeners != null) {
@@ -485,6 +487,9 @@
synchronized (mLock) {
List<MediaSessionRecord> records = mPriorityStack.getActiveSessions(userId);
int size = records.size();
+ if (size > 0) {
+ persistMediaButtonReceiverLocked(records.get(0));
+ }
ArrayList<MediaSessionToken> tokens = new ArrayList<MediaSessionToken>();
for (int i = 0; i < size; i++) {
tokens.add(new MediaSessionToken(records.get(i).getControllerBinder()));
@@ -504,6 +509,16 @@
}
}
+ private void persistMediaButtonReceiverLocked(MediaSessionRecord record) {
+ ComponentName receiver = record.getMediaButtonReceiver();
+ if (receiver != null) {
+ Settings.System.putStringForUser(mContentResolver,
+ Settings.System.MEDIA_BUTTON_RECEIVER,
+ receiver == null ? "" : receiver.flattenToString(),
+ UserHandle.USER_CURRENT);
+ }
+ }
+
private MediaRouteProviderProxy.RoutesListener mRoutesCallback
= new MediaRouteProviderProxy.RoutesListener() {
@Override