Bug 923173 - Use NS_WARNING for unexpected name to avoid crashing. r=ehsan
authorMarco Chen <mchen@mozilla.com>
Mon, 14 Oct 2013 18:45:35 +0800
changeset 164461 4a5442007b43d0cf7176cf2b018404bd7bacc90e
parent 164460 1192f75d0d22eaa51c2f945cc485a8c1f5d97e48
child 164462 f6f83e7e2bfaf30a614fba7e311e402fbcd5b4a3
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs923173
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 923173 - Use NS_WARNING for unexpected name to avoid crashing. r=ehsan
dom/audiochannel/AudioChannelService.cpp
dom/system/gonk/AudioManager.cpp
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -698,18 +698,23 @@ AudioChannelService::Observe(nsISupports
     if (keyStr.EqualsLiteral("audio.volume.content")) {
       audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_CONTENT, index);
     } else if (keyStr.EqualsLiteral("audio.volume.notification")) {
       audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_NOTIFICATION, index);
     } else if (keyStr.EqualsLiteral("audio.volume.alarm")) {
       audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_ALARM, index);
     } else if (keyStr.EqualsLiteral("audio.volume.telephony")) {
       audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_TELEPHONY, index);
-    } else {
-      MOZ_ASSUME_UNREACHABLE("unexpected audio channel for volume control");
+    } else if (!keyStr.EqualsLiteral("audio.volume.bt_sco")) {
+      // bt_sco is not a valid audio channel so we manipulate it in
+      // AudioManager.cpp. And the others should not be used.
+      // We didn't use MOZ_ASSUME_UNREACHABLE here because any web content who
+      // has permission of mozSettings can set any names then it can be easy to
+      // crash the B2G.
+      NS_WARNING("unexpected audio channel for volume control");
     }
   }
 #endif
 
   return NS_OK;
 }
 
 AudioChannelService::AudioChannelInternalType
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -133,17 +133,18 @@ public:
     } else if (aName.EqualsLiteral("audio.volume.alarm")) {
       audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_ALARM, volIndex);
     } else if (aName.EqualsLiteral("audio.volume.telephony")) {
       audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_TELEPHONY, volIndex);
     } else if (aName.EqualsLiteral("audio.volume.bt_sco")) {
       static_cast<AudioManager *>(audioManager.get())->SetStreamVolumeIndex(
         AUDIO_STREAM_BLUETOOTH_SCO, volIndex);
     } else {
-      MOZ_ASSUME_UNREACHABLE("unexpected audio channel for volume control");
+      MOZ_ASSUME_UNREACHABLE("unexpected audio channel for initializing "
+                             "volume control");
     }
 
     return NS_OK;
   }
 
   NS_IMETHOD HandleError(const nsAString& aName)
   {
     LOG("AudioChannelVolInitCallback::HandleError: %s\n",