summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDvTonder <david.vantonder@gmail.com>2012-12-06 17:39:29 -0500
committerDvTonder <david.vantonder@gmail.com>2012-12-06 17:39:29 -0500
commit9df1aa5fb865dc8d06795108d3dc8c1371f17b3a (patch)
tree6c9d908bed90336ec8d5fb36b178bbf8c9f948b7
parentea28c5a080b84f2c8673592d72afc75110e94dfd (diff)
downloadframeworks_base-9df1aa5fb865dc8d06795108d3dc8c1371f17b3a.zip
frameworks_base-9df1aa5fb865dc8d06795108d3dc8c1371f17b3a.tar.gz
frameworks_base-9df1aa5fb865dc8d06795108d3dc8c1371f17b3a.tar.bz2
Audioservice: Fix Theme engine support
A few more instances of mVolumePanel.postXXXX had to be enclosed in a null pointer avoidance wrapper. Change-Id: I60a0544b5a785417af1ea61e7322b06f2748876b
-rw-r--r--media/java/android/media/AudioService.java132
1 files changed, 123 insertions, 9 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 0fde942..ed7dbac 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -1106,7 +1106,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
// UI update and Broadcast Intent
private void sendMasterVolumeUpdate(int flags, int oldVolume, int newVolume) {
- mVolumePanel.postMasterVolumeChanged(flags);
+ masterVolumeChanged(flags);
Intent intent = new Intent(AudioManager.MASTER_VOLUME_CHANGED_ACTION);
intent.putExtra(AudioManager.EXTRA_PREV_MASTER_VOLUME_VALUE, oldVolume);
@@ -1116,7 +1116,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
// UI update and Broadcast Intent
private void sendMasterMuteUpdate(boolean muted, int flags) {
- mVolumePanel.postMasterMuteChanged(flags);
+ masterMuteChanged(flags);
broadcastMasterMuteStatus(muted);
}
@@ -2313,7 +2313,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
if (mMusicActiveMs > UNSAFE_VOLUME_MUSIC_ACTIVE_MS_MAX) {
setSafeMediaVolumeEnabled(true);
mMusicActiveMs = 0;
- mVolumePanel.postDisplaySafeVolumeWarning();
+ displaySafeVolumeWarning();
}
}
}
@@ -3974,6 +3974,63 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
}
}
+ private void masterVolumeChanged(final int flags) {
+ if (mUiContext != null && mVolumePanel != null) {
+ mVolumePanel.postMasterVolumeChanged(flags);
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+
+ final Context context = mUiContext != null ? mUiContext : mContext;
+ mVolumePanel = new VolumePanel(context, AudioService.this);
+ mVolumePanel.postMasterVolumeChanged(flags);
+ }
+ });
+ }
+ }
+
+ private void masterMuteChanged(final int flags) {
+ if (mUiContext != null && mVolumePanel != null) {
+ mVolumePanel.postMasterMuteChanged(flags);
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+
+ final Context context = mUiContext != null ? mUiContext : mContext;
+ mVolumePanel = new VolumePanel(context, AudioService.this);
+ mVolumePanel.postMasterMuteChanged(flags);
+ }
+ });
+ }
+ }
+
+ private void remoteSliderVisibility(final boolean hasRemotePlayback) {
+ if (mUiContext != null && mVolumePanel != null) {
+ mVolumePanel.postRemoteSliderVisibility(hasRemotePlayback);
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+
+ final Context context = mUiContext != null ? mUiContext : mContext;
+ mVolumePanel = new VolumePanel(context, AudioService.this);
+ mVolumePanel.postRemoteSliderVisibility(hasRemotePlayback);
+ }
+ });
+ }
+ }
+
private void showVolumeChangeUi(final int streamType, final int flags) {
if (mUiContext != null && mVolumePanel != null) {
mVolumePanel.postVolumeChanged(streamType, flags);
@@ -3993,6 +4050,63 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
}
}
+ private void remoteVolumeChanged(final int streamType, final int flags) {
+ if (mUiContext != null && mVolumePanel != null) {
+ mVolumePanel.postRemoteVolumeChanged(streamType, flags);
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+
+ final Context context = mUiContext != null ? mUiContext : mContext;
+ mVolumePanel = new VolumePanel(context, AudioService.this);
+ mVolumePanel.postRemoteVolumeChanged(streamType, flags);
+ }
+ });
+ }
+ }
+
+ private void displaySafeVolumeWarning() {
+ if (mUiContext != null && mVolumePanel != null) {
+ mVolumePanel.postDisplaySafeVolumeWarning();
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+
+ final Context context = mUiContext != null ? mUiContext : mContext;
+ mVolumePanel = new VolumePanel(context, AudioService.this);
+ mVolumePanel.postDisplaySafeVolumeWarning();
+ }
+ });
+ }
+ }
+
+ private void hasNewRemotePlaybackInfo() {
+ if (mUiContext != null && mVolumePanel != null) {
+ mVolumePanel.postHasNewRemotePlaybackInfo();
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mUiContext == null) {
+ mUiContext = ThemeUtils.createUiContext(mContext);
+ }
+
+ final Context context = mUiContext != null ? mUiContext : mContext;
+ mVolumePanel = new VolumePanel(context, AudioService.this);
+ mVolumePanel.postHasNewRemotePlaybackInfo();
+ }
+ });
+ }
+ }
+
//==========================================================================================
// AudioFocus
//==========================================================================================
@@ -5502,7 +5616,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
synchronized (mMainRemote) {
if (rccId == mMainRemote.mRccId) {
mMainRemote.mVolume = value;
- mVolumePanel.postHasNewRemotePlaybackInfo();
+ hasNewRemotePlaybackInfo();
}
}
break;
@@ -5511,7 +5625,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
synchronized (mMainRemote) {
if (rccId == mMainRemote.mRccId) {
mMainRemote.mVolumeMax = value;
- mVolumePanel.postHasNewRemotePlaybackInfo();
+ hasNewRemotePlaybackInfo();
}
}
break;
@@ -5520,7 +5634,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
synchronized (mMainRemote) {
if (rccId == mMainRemote.mRccId) {
mMainRemote.mVolumeHandling = value;
- mVolumePanel.postHasNewRemotePlaybackInfo();
+ hasNewRemotePlaybackInfo();
}
}
break;
@@ -5638,7 +5752,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
}
// fire up the UI
- mVolumePanel.postRemoteVolumeChanged(streamType, flags);
+ remoteVolumeChanged(streamType, flags);
}
private void sendVolumeUpdateToRemote(int rccId, int direction) {
@@ -5742,7 +5856,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
synchronized (mMainRemote) {
if (mHasRemotePlayback != hasRemotePlayback) {
mHasRemotePlayback = hasRemotePlayback;
- mVolumePanel.postRemoteSliderVisibility(hasRemotePlayback);
+ remoteSliderVisibility(hasRemotePlayback);
}
}
}
@@ -5977,7 +6091,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
(mStreamVolumeAlias[streamType] == AudioSystem.STREAM_MUSIC) &&
((device & mSafeMediaVolumeDevices) != 0) &&
(index > mSafeMediaVolumeIndex)) {
- mVolumePanel.postDisplaySafeVolumeWarning();
+ displaySafeVolumeWarning();
return false;
}
return true;