javauis/mmapi_akn/baseline/javasrc/com/nokia/microedition/media/control/VolumeControl.java
branchRCL_3
changeset 21 4376525cdefb
parent 14 04becd199f91
--- a/javauis/mmapi_akn/baseline/javasrc/com/nokia/microedition/media/control/VolumeControl.java	Wed Jun 09 09:34:07 2010 +0300
+++ b/javauis/mmapi_akn/baseline/javasrc/com/nokia/microedition/media/control/VolumeControl.java	Mon Jun 21 15:32:50 2010 +0300
@@ -18,12 +18,20 @@
 
 package com.nokia.microedition.media.control;
 
+import com.nokia.mj.impl.rt.support.ApplicationInfo;
+import com.nokia.mj.impl.utils.Tokenizer;
+import javax.microedition.media.Player;
+
 public class VolumeControl extends ControlImpl
         implements javax.microedition.media.control.VolumeControl
 {
     private static final int MAX_VOLUME = 100;
     private static final int UNDEFINED_VOLUME = -1;
-
+    private static final String SEPARATOR = ",";
+    private static final String ATTRIB_NOKIA_UI_ENHANCEMENT =
+        "Nokia-UI-Enhancement";
+    private static final String IGNORE_PROFILES_BASED_SOUNDING =
+        "IgnoreProfilesBasedSoundMuting";
     // these constants come from native side
     protected static final int NO_ERROR = 0; // native side returns if OK
 
@@ -41,6 +49,44 @@
         return iMuted;
     }
 
+    /**
+     * Set handles
+     * @param aPlayer Player instance
+     * @param aEventSource Handle to event source
+     * @param aControlHandle Handle Handle to control
+     */
+    public void setHandles(Player aPlayer,
+                           int aEventSource,
+                           int aControlHandle)
+    {
+        super.setHandles(aPlayer, aEventSource, aControlHandle);
+        boolean ignoreProfileBasedSoundMuting = false;
+        String attrib = ApplicationInfo.getInstance().getAttribute(
+                            ATTRIB_NOKIA_UI_ENHANCEMENT);
+        String[] parsedAttributes = Tokenizer.split( attrib, SEPARATOR);
+        if (parsedAttributes != null)
+        {
+            for (int i = 0; i < parsedAttributes.length; i++)
+            {
+                if (IGNORE_PROFILES_BASED_SOUNDING.equalsIgnoreCase(
+                            parsedAttributes[i]))
+                {
+                    ignoreProfileBasedSoundMuting = true;
+                    break;
+                }
+            }
+        }
+        if (!ignoreProfileBasedSoundMuting)
+        {
+            int err =_setProfilesBasedSoundMuting(aEventSource, aControlHandle);
+            if (err < NO_ERROR)
+            {
+                throw new Error("Setting profile based sound " +
+                                          "muting failed" + err);
+            }
+        }
+    }
+
     public int getLevel()
     {
         checkState();
@@ -117,4 +163,7 @@
     private static native int _setLevel(int aEventSource, int aControlHandle,
                                         int aLevel);
     private static native int _getLevel(int aEventSource, int aControlHandle);
+
+    private static native int _setProfilesBasedSoundMuting(int aEventSource,
+            int aControlHandle);
 }