Merge "Set country code in the driver and remove channel set"
diff --git a/api/current.xml b/api/current.xml
index ed9ed53..07f298e 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -14275,7 +14275,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973949"
+ value="16973951"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -14286,7 +14286,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973950"
+ value="16973952"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -14436,6 +14436,17 @@
  visibility="public"
 >
 </field>
+<field name="Theme_Holo_Dialog_Alert"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973945"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="Theme_Holo_Extended"
  type="int"
  transient="false"
@@ -14469,6 +14480,17 @@
  visibility="public"
 >
 </field>
+<field name="Theme_Holo_Light_Dialog_Alert"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973946"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="Theme_Holo_Light_Extended"
  type="int"
  transient="false"
@@ -14781,7 +14803,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973948"
+ value="16973950"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -14792,7 +14814,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973947"
+ value="16973949"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -14946,7 +14968,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973951"
+ value="16973953"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15012,7 +15034,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973945"
+ value="16973947"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15067,7 +15089,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973946"
+ value="16973948"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -19457,9 +19479,41 @@
 >
 <parameter name="tab" type="android.app.ActionBar.Tab">
 </parameter>
+<parameter name="setSelected" type="boolean">
+</parameter>
+</method>
+<method name="addTab"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="tab" type="android.app.ActionBar.Tab">
+</parameter>
 <parameter name="position" type="int">
 </parameter>
 </method>
+<method name="addTab"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="tab" type="android.app.ActionBar.Tab">
+</parameter>
+<parameter name="position" type="int">
+</parameter>
+<parameter name="setSelected" type="boolean">
+</parameter>
+</method>
 <method name="getCustomNavigationView"
  return="android.view.View"
  abstract="true"
@@ -68707,29 +68761,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="2012"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="TYPE_FINALIZE_FAILED"
- type="int"
- transient="false"
- volatile="false"
- value="2010"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="TYPE_INITIALIZE_FAILED"
- type="int"
- transient="false"
- volatile="false"
- value="2009"
+ value="2008"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -68769,7 +68801,7 @@
  visibility="public"
 >
 </field>
-<field name="TYPE_REGISTRATION_FAILED"
+<field name="TYPE_PROCESS_DRM_INFO_FAILED"
  type="int"
  transient="false"
  volatile="false"
@@ -68784,18 +68816,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="2011"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="TYPE_RIGHTS_ACQUISITION_FAILED"
- type="int"
- transient="false"
- volatile="false"
- value="2008"
+ value="2007"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -68824,17 +68845,6 @@
  visibility="public"
 >
 </field>
-<field name="TYPE_UNREGISTRATION_FAILED"
- type="int"
- transient="false"
- volatile="false"
- value="2007"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 </class>
 <class name="DrmEvent"
  extends="java.lang.Object"
@@ -68917,7 +68927,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="1006"
+ value="1001"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -68928,28 +68938,6 @@
  type="int"
  transient="false"
  volatile="false"
- value="1007"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="TYPE_FINALIZED"
- type="int"
- transient="false"
- volatile="false"
- value="1001"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="TYPE_INITIALIZED"
- type="int"
- transient="false"
- volatile="false"
  value="1003"
  static="true"
  final="true"
@@ -68957,7 +68945,7 @@
  visibility="public"
 >
 </field>
-<field name="TYPE_REGISTERED"
+<field name="TYPE_DRM_INFO_PROCESSED"
  type="int"
  transient="false"
  volatile="false"
@@ -68968,28 +68956,6 @@
  visibility="public"
 >
 </field>
-<field name="TYPE_RIGHTS_ACQUIRED"
- type="int"
- transient="false"
- volatile="false"
- value="1005"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="TYPE_UNREGISTERED"
- type="int"
- transient="false"
- volatile="false"
- value="1004"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 </class>
 <class name="DrmInfo"
  extends="java.lang.Object"
@@ -69365,6 +69331,8 @@
 >
 <parameter name="_statusCode" type="int">
 </parameter>
+<parameter name="_infoType" type="int">
+</parameter>
 <parameter name="_data" type="android.drm.ProcessedData">
 </parameter>
 <parameter name="_mimeType" type="java.lang.String">
@@ -69402,6 +69370,16 @@
  visibility="public"
 >
 </field>
+<field name="infoType"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="mimeType"
  type="java.lang.String"
  transient="false"
@@ -69665,17 +69643,6 @@
 <parameter name="uri" type="android.net.Uri">
 </parameter>
 </method>
-<method name="loadPlugIns"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
 <method name="openConvertSession"
  return="int"
  abstract="false"
@@ -69797,17 +69764,6 @@
 <parameter name="infoListener" type="android.drm.DrmManagerClient.OnInfoListener">
 </parameter>
 </method>
-<method name="unloadPlugIns"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
 <field name="ERROR_NONE"
  type="int"
  transient="false"
@@ -196846,6 +196802,17 @@
  visibility="public"
 >
 </field>
+<field name="KEYCODE_VOLUME_MUTE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="164"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="KEYCODE_VOLUME_UP"
  type="int"
  transient="false"
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java
index b359ce6..e185624 100644
--- a/core/java/android/app/ActionBar.java
+++ b/core/java/android/app/ActionBar.java
@@ -397,14 +397,24 @@
 
     /**
      * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
+     * If this is the first tab to be added it will become the selected tab.
      *
      * @param tab Tab to add
      */
     public abstract void addTab(Tab tab);
 
     /**
+     * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
+     *
+     * @param tab Tab to add
+     * @param setSelected True if the added tab should become the selected tab.
+     */
+    public abstract void addTab(Tab tab, boolean setSelected);
+
+    /**
      * Add a tab for use in tabbed navigation mode. The tab will be inserted at
-     * <code>position</code>.
+     * <code>position</code>. If this is the first tab to be added it will become
+     * the selected tab.
      *
      * @param tab The tab to add
      * @param position The new position of the tab
@@ -412,6 +422,16 @@
     public abstract void addTab(Tab tab, int position);
 
     /**
+     * Add a tab for use in tabbed navigation mode. The tab will be insterted at
+     * <code>position</code>.
+     *
+     * @param tab The tab to add
+     * @param position The new position of the tab
+     * @param setSelected True if the added tab should become the selected tab.
+     */
+    public abstract void addTab(Tab tab, int position, boolean setSelected);
+
+    /**
      * Remove a tab from the action bar. If the removed tab was selected it will be deselected
      * and another tab will be selected if present.
      *
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index 1fae516..e3242c1 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -39,13 +39,17 @@
  * </ul>
  *
  * <p>
- * Each of the notify methods takes an int id parameter.  This id identifies
- * this notification from your app to the system, so that id should be unique
- * within your app.  If you call one of the notify methods with an id that is
- * currently active and a new set of notification parameters, it will be
- * updated.  For example, if you pass a new status bar icon, the old icon in
- * the status bar will be replaced with the new one.  This is also the same
- * id you pass to the {@link #cancel} method to clear this notification.
+ * Each of the notify methods takes an int id parameter and optionally a
+ * {@link String} tag parameter, which may be {@code null}.  These parameters
+ * are used to form a pair (tag, id), or ({@code null}, id) if tag is
+ * unspecified.  This pair identifies this notification from your app to the
+ * system, so that pair should be unique within your app.  If you call one
+ * of the notify methods with a (tag, id) pair that is currently active and
+ * a new set of notification parameters, it will be updated.  For example,
+ * if you pass a new status bar icon, the old icon in the status bar will
+ * be replaced with the new one.  This is also the same tag and id you pass
+ * to the {@link #cancel(int)} or {@link #cancel(String, int)} method to clear
+ * this notification.
  *
  * <p>
  * You do not instantiate this class directly; instead, retrieve it through
@@ -94,12 +98,11 @@
     /**
      * Persistent notification on the status bar,
      *
-     * @param tag An string identifier for this notification unique within your
-     *        application.
+     * @param tag A string identifier for this notification.  May be {@code null}.
+     * @param id An identifier for this notification.  The pair (tag, id) must be unique
+     *        within your application.
      * @param notification A {@link Notification} object describing how to
      *        notify the user, other than the view you're providing. Must not be null.
-     * @return the id of the notification that is associated with the string identifier that
-     * can be used to cancel the notification
      */
     public void notify(String tag, int id, Notification notification)
     {
diff --git a/core/java/android/database/Cursor.java b/core/java/android/database/Cursor.java
index a344272..a9a71cf 100644
--- a/core/java/android/database/Cursor.java
+++ b/core/java/android/database/Cursor.java
@@ -212,7 +212,9 @@
     /**
      * Returns the value of the requested column as a byte array.
      *
-     * <p>If the native content of that column is not blob exception may throw
+     * <p>The result and whether this method throws an exception when the
+     * column value is null or the column type is not a blob type is
+     * implementation-defined.
      *
      * @param columnIndex the zero-based index of the target column.
      * @return the value of that column as a byte array.
@@ -222,8 +224,9 @@
     /**
      * Returns the value of the requested column as a String.
      *
-     * <p>If the native content of that column is not text the result will be
-     * the result of passing the column value to String.valueOf(x).
+     * <p>The result and whether this method throws an exception when the
+     * column value is null or the column type is not a string type is
+     * implementation-defined.
      *
      * @param columnIndex the zero-based index of the target column.
      * @return the value of that column as a String.
@@ -243,8 +246,10 @@
     /**
      * Returns the value of the requested column as a short.
      *
-     * <p>If the native content of that column is not numeric the result will be
-     * the result of passing the column value to Short.valueOf(x).
+     * <p>The result and whether this method throws an exception when the
+     * column value is null, the column type is not an integral type, or the
+     * integer value is outside the range [<code>Short.MIN_VALUE</code>,
+     * <code>Short.MAX_VALUE</code>] is implementation-defined.
      *
      * @param columnIndex the zero-based index of the target column.
      * @return the value of that column as a short.
@@ -254,8 +259,10 @@
     /**
      * Returns the value of the requested column as an int.
      *
-     * <p>If the native content of that column is not numeric the result will be
-     * the result of passing the column value to Integer.valueOf(x).
+     * <p>The result and whether this method throws an exception when the
+     * column value is null, the column type is not an integral type, or the
+     * integer value is outside the range [<code>Integer.MIN_VALUE</code>,
+     * <code>Integer.MAX_VALUE</code>] is implementation-defined.
      *
      * @param columnIndex the zero-based index of the target column.
      * @return the value of that column as an int.
@@ -265,8 +272,10 @@
     /**
      * Returns the value of the requested column as a long.
      *
-     * <p>If the native content of that column is not numeric the result will be
-     * the result of passing the column value to Long.valueOf(x).
+     * <p>The result and whether this method throws an exception when the
+     * column value is null, the column type is not an integral type, or the
+     * integer value is outside the range [<code>Long.MIN_VALUE</code>,
+     * <code>Long.MAX_VALUE</code>] is implementation-defined.
      *
      * @param columnIndex the zero-based index of the target column.
      * @return the value of that column as a long.
@@ -276,8 +285,10 @@
     /**
      * Returns the value of the requested column as a float.
      *
-     * <p>If the native content of that column is not numeric the result will be
-     * the result of passing the column value to Float.valueOf(x).
+     * <p>The result and whether this method throws an exception when the
+     * column value is null, the column type is not a floating-point type, or the
+     * floating-point value is not representable as a <code>float</code> value is
+     * implementation-defined.
      *
      * @param columnIndex the zero-based index of the target column.
      * @return the value of that column as a float.
@@ -287,8 +298,10 @@
     /**
      * Returns the value of the requested column as a double.
      *
-     * <p>If the native content of that column is not numeric the result will be
-     * the result of passing the column value to Double.valueOf(x).
+     * <p>The result and whether this method throws an exception when the
+     * column value is null, the column type is not a floating-point type, or the
+     * floating-point value is not representable as a <code>double</code> value is
+     * implementation-defined.
      *
      * @param columnIndex the zero-based index of the target column.
      * @return the value of that column as a double.
@@ -420,7 +433,8 @@
      * that are required to fetch data for the cursor.
      *
      * <p>These values may only change when requery is called.
-     * @return cursor-defined values, or Bundle.EMTPY if there are no values. Never null.
+     * @return cursor-defined values, or {@link android.os.Bundle#EMPTY Bundle.EMPTY} if there
+     *         are no values. Never <code>null</code>.
      */
     Bundle getExtras();
 
@@ -430,8 +444,10 @@
      *
      * <p>One use of this is to tell a cursor that it should retry its network request after it
      * reported an error.
-     * @param extras extra values, or Bundle.EMTPY. Never null.
-     * @return extra values, or Bundle.EMTPY. Never null.
+     * @param extras extra values, or {@link android.os.Bundle#EMPTY Bundle.EMPTY}.
+     *         Never <code>null</code>.
+     * @return extra values, or {@link android.os.Bundle#EMPTY Bundle.EMPTY}.
+     *         Never <code>null</code>.
      */
     Bundle respond(Bundle extras);
 }
diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java
index 599431f..a026eca 100644
--- a/core/java/android/database/CursorWindow.java
+++ b/core/java/android/database/CursorWindow.java
@@ -240,6 +240,15 @@
         }
     }
 
+    /**
+     * Returns the value at (<code>row</code>, <code>col</code>) as a <code>byte</code> array.
+     *
+     * <p>If the value is null, then <code>null</code> is returned. If the
+     * type of column <code>col</code> is a string type, then the result
+     * is the array of bytes that make up the internal representation of the
+     * string value. If the type of column <code>col</code> is integral or floating-point,
+     * then an {@link SQLiteException} is thrown.
+     */
     private native byte[] getBlob_native(int row, int col);
 
     /**
@@ -340,6 +349,19 @@
         }
     }
     
+    /**
+     * Returns the value at (<code>row</code>, <code>col</code>) as a <code>String</code>.
+     *
+     * <p>If the value is null, then <code>null</code> is returned. If the
+     * type of column <code>col</code> is integral, then the result is the string
+     * that is obtained by formatting the integer value with the <code>printf</code>
+     * family of functions using format specifier <code>%lld</code>. If the
+     * type of column <code>col</code> is floating-point, then the result is the string
+     * that is obtained by formatting the floating-point value with the
+     * <code>printf</code> family of functions using format specifier <code>%g</code>.
+     * If the type of column <code>col</code> is a blob type, then an
+     * {@link SQLiteException} is thrown.
+     */
     private native String getString_native(int row, int col);
 
     /**
@@ -391,6 +413,17 @@
         }
     }
     
+    /**
+     * Returns the value at (<code>row</code>, <code>col</code>) as a <code>long</code>.
+     *
+     * <p>If the value is null, then <code>0L</code> is returned. If the
+     * type of column <code>col</code> is a string type, then the result
+     * is the <code>long</code> that is obtained by parsing the string value with
+     * <code>strtoll</code>. If the type of column <code>col</code> is
+     * floating-point, then the result is the floating-point value casted to a <code>long</code>.
+     * If the type of column <code>col</code> is a blob type, then an
+     * {@link SQLiteException} is thrown.
+     */
     private native long getLong_native(int row, int col);
 
     /**
@@ -410,6 +443,17 @@
         }
     }
     
+    /**
+     * Returns the value at (<code>row</code>, <code>col</code>) as a <code>double</code>.
+     *
+     * <p>If the value is null, then <code>0.0</code> is returned. If the
+     * type of column <code>col</code> is a string type, then the result
+     * is the <code>double</code> that is obtained by parsing the string value with
+     * <code>strtod</code>. If the type of column <code>col</code> is
+     * integral, then the result is the integer value casted to a <code>double</code>.
+     * If the type of column <code>col</code> is a blob type, then an
+     * {@link SQLiteException} is thrown.
+     */
     private native double getDouble_native(int row, int col);
 
     /**
diff --git a/core/java/android/nfc/ILlcpServiceSocket.aidl b/core/java/android/nfc/ILlcpServiceSocket.aidl
index c3108dc..581c21d 100644
--- a/core/java/android/nfc/ILlcpServiceSocket.aidl
+++ b/core/java/android/nfc/ILlcpServiceSocket.aidl
@@ -23,6 +23,4 @@
 {
     int accept(int nativeHandle);
     void close(int nativeHandle);
-    int getAcceptTimeout(int nativeHandle);
-    void setAcceptTimeout(int nativeHandle, int timeout);
 }
diff --git a/core/java/android/nfc/ILlcpSocket.aidl b/core/java/android/nfc/ILlcpSocket.aidl
index dda5628..3166e72 100644
--- a/core/java/android/nfc/ILlcpSocket.aidl
+++ b/core/java/android/nfc/ILlcpSocket.aidl
@@ -24,7 +24,6 @@
     int close(int nativeHandle);
     int connect(int nativeHandle, int sap);
     int connectByName(int nativeHandle, String sn);
-    int getConnectTimeout(int nativeHandle);
     int getLocalSap(int nativeHandle);
     int getLocalSocketMiu(int nativeHandle);
     int getLocalSocketRw(int nativeHandle);
@@ -32,5 +31,4 @@
     int getRemoteSocketRw(int nativeHandle);
     int receive(int nativeHandle, out byte[] receiveBuffer);
     int send(int nativeHandle, in byte[] data);
-    void setConnectTimeout(int nativeHandle, int timeout);
 }
\ No newline at end of file
diff --git a/core/java/android/nfc/NdefMessage.java b/core/java/android/nfc/NdefMessage.java
index d107b54..c79fabf 100644
--- a/core/java/android/nfc/NdefMessage.java
+++ b/core/java/android/nfc/NdefMessage.java
@@ -16,7 +16,6 @@
 
 package android.nfc;
 
-import android.nfc.NdefRecord;
 import android.os.Parcel;
 import android.os.Parcelable;
 
@@ -69,11 +68,10 @@
      * Returns a byte array representation of this entire NDEF message.
      */
     public byte[] toByteArray() {
-        //TODO: do not return null
         //TODO: allocate the byte array once, copy each record once
         //TODO: process MB and ME flags outside loop
         if ((mRecords == null) || (mRecords.length == 0))
-            return null;
+            return new byte[0];
 
         byte[] msg = {};
 
@@ -104,10 +102,12 @@
         return msg;
     }
 
+    @Override
     public int describeContents() {
         return 0;
     }
 
+    @Override
     public void writeToParcel(Parcel dest, int flags) {
         dest.writeInt(mRecords.length);
         dest.writeTypedArray(mRecords, flags);
@@ -115,12 +115,14 @@
 
     public static final Parcelable.Creator<NdefMessage> CREATOR =
             new Parcelable.Creator<NdefMessage>() {
+        @Override
         public NdefMessage createFromParcel(Parcel in) {
             int recordsLength = in.readInt();
             NdefRecord[] records = new NdefRecord[recordsLength];
             in.readTypedArray(records, NdefRecord.CREATOR);
             return new NdefMessage(records);
         }
+        @Override
         public NdefMessage[] newArray(int size) {
             return new NdefMessage[size];
         }
diff --git a/core/java/android/preference/VolumePreference.java b/core/java/android/preference/VolumePreference.java
index 970d520..66c9ba1 100644
--- a/core/java/android/preference/VolumePreference.java
+++ b/core/java/android/preference/VolumePreference.java
@@ -92,6 +92,11 @@
                     mSeekBarVolumizer.changeVolumeBy(1);
                 }
                 return true;
+            case KeyEvent.KEYCODE_VOLUME_MUTE:
+                if (isdown) {
+                    mSeekBarVolumizer.muteVolume();
+                }
+                return true;
             default:
                 return false;
         }
@@ -225,6 +230,7 @@
     
         private int mLastProgress = -1;
         private SeekBar mSeekBar;
+        private int mVolumeBeforeMute = -1;
         
         private ContentObserver mVolumeObserver = new ContentObserver(mHandler) {
             @Override
@@ -336,6 +342,21 @@
                 sample();
             }
             postSetVolume(mSeekBar.getProgress());
+            mVolumeBeforeMute = -1;
+        }
+
+        public void muteVolume() {
+            if (mVolumeBeforeMute != -1) {
+                mSeekBar.setProgress(mVolumeBeforeMute);
+                sample();
+                postSetVolume(mVolumeBeforeMute);
+                mVolumeBeforeMute = -1;
+            } else {
+                mVolumeBeforeMute = mSeekBar.getProgress();
+                mSeekBar.setProgress(0);
+                stopSample();
+                postSetVolume(0);
+            }
         }
 
         public void onSaveInstanceState(VolumeStore volumeStore) {
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 0e75682..04c331f 100755
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -125,9 +125,11 @@
     /** Key code constant: Directional Pad Center key.
      * May also be synthesized from trackball motions. */
     public static final int KEYCODE_DPAD_CENTER     = 23;
-    /** Key code constant: Volume Up key. */
+    /** Key code constant: Volume Up key.
+     * Adjusts the speaker volume up. */
     public static final int KEYCODE_VOLUME_UP       = 24;
-    /** Key code constant: Volume Down key. */
+    /** Key code constant: Volume Down key.
+     * Adjusts the speaker volume down. */
     public static final int KEYCODE_VOLUME_DOWN     = 25;
     /** Key code constant: Power key. */
     public static final int KEYCODE_POWER           = 26;
@@ -269,7 +271,8 @@
     public static final int KEYCODE_MEDIA_REWIND    = 89;
     /** Key code constant: Fast Forward media key. */
     public static final int KEYCODE_MEDIA_FAST_FORWARD = 90;
-    /** Key code constant: Mute key. */
+    /** Key code constant: Mute key.
+     * Mutes the microphone, unlike {@link #KEYCODE_VOLUME_MUTE}. */
     public static final int KEYCODE_MUTE            = 91;
     /** Key code constant: Page Up key. */
     public static final int KEYCODE_PAGE_UP         = 92;
@@ -455,8 +458,13 @@
     public static final int KEYCODE_NUMPAD_LEFT_PAREN = 162;
     /** Key code constant: Numeric keypad ')' key. */
     public static final int KEYCODE_NUMPAD_RIGHT_PAREN = 163;
+    /** Key code constant: Volume Mute key.
+     * Mutes the speaker, unlike {@link #KEYCODE_MUTE}.
+     * This key should normally be implemented as a toggle such that the first press
+     * mutes the speaker and the second press restores the original volume. */
+    public static final int KEYCODE_VOLUME_MUTE     = 164;
 
-    private static final int LAST_KEYCODE           = KEYCODE_NUMPAD_RIGHT_PAREN;
+    private static final int LAST_KEYCODE           = KEYCODE_VOLUME_MUTE;
 
     // NOTE: If you add a new keycode here you must also add it to:
     //  isSystem()
@@ -640,6 +648,7 @@
         "KEYCODE_NUMPAD_EQUALS",
         "KEYCODE_NUMPAD_LEFT_PAREN",
         "KEYCODE_NUMPAD_RIGHT_PAREN",
+        "KEYCODE_VOLUME_MUTE",
     };
 
     // Symbolic names of all metakeys in bit order from least significant to most significant.
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 0f9312c..ad343a3 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -870,7 +870,7 @@
         switch (event.mAction) {
         case DragEvent.ACTION_DRAG_STARTED: {
             // clear state to recalculate which views we drag over
-            root.setDragFocus(event, null);
+            mCurrentDragView = null;
 
             // Now dispatch down to our children, caching the responses
             mChildAcceptsDrag = false;
@@ -915,11 +915,28 @@
             final View target = findFrontmostDroppableChildAt(event.mX, event.mY, mLocalPoint);
 
             // If we've changed apparent drag target, tell the view root which view
-            // we're over now.  This will in turn send out DRAG_ENTERED / DRAG_EXITED
-            // notifications as appropriate.
+            // we're over now [for purposes of the eventual drag-recipient-changed
+            // notifications to the framework] and tell the new target that the drag
+            // has entered its bounds.  The root will see setDragFocus() calls all
+            // the way down to the final leaf view that is handling the LOCATION event
+            // before reporting the new potential recipient to the framework.
             if (mCurrentDragView != target) {
-                root.setDragFocus(event, target);
+                root.setDragFocus(target);
+
+                final int action = event.mAction;
+                // If we've dragged off of a child view, send it the EXITED message
+                if (mCurrentDragView != null) {
+                    event.mAction = DragEvent.ACTION_DRAG_EXITED;
+                    mCurrentDragView.dispatchDragEvent(event);
+                }
                 mCurrentDragView = target;
+
+                // If we've dragged over a new child view, send it the ENTERED message
+                if (target != null) {
+                    event.mAction = DragEvent.ACTION_DRAG_ENTERED;
+                    target.dispatchDragEvent(event);
+                }
+                event.mAction = action;  // restore the event's original state
             }
 
             // Dispatch the actual drag location notice, localized into its coordinates
@@ -934,6 +951,25 @@
             }
         } break;
 
+        /* Entered / exited dispatch
+         *
+         * DRAG_ENTERED is not dispatched downwards from ViewGroup.  The reason for this is
+         * that we're about to get the corresponding LOCATION event, which we will use to
+         * determine which of our children is the new target; at that point we will
+         * push a DRAG_ENTERED down to the new target child [which may itself be a ViewGroup].
+         *
+         * DRAG_EXITED *is* dispatched all the way down immediately: once we know the
+         * drag has left this ViewGroup, we know by definition that every contained subview
+         * is also no longer under the drag point.
+         */
+
+        case DragEvent.ACTION_DRAG_EXITED: {
+            if (mCurrentDragView != null) {
+                mCurrentDragView.dispatchDragEvent(event);
+                mCurrentDragView = null;
+            }
+        } break;
+
         case DragEvent.ACTION_DROP: {
             if (ViewDebug.DEBUG_DRAG) Log.d(View.VIEW_LOG_TAG, "Drop event: " + event);
             View target = findFrontmostDroppableChildAt(event.mX, event.mY, mLocalPoint);
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 22a7773..c7c2071 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -2493,11 +2493,12 @@
                 // a window boundary, so the current drag target within this one must have
                 // just been exited.  Send it the usual notifications and then we're done
                 // for now.
-                setDragFocus(event, null);
+                mView.dispatchDragEvent(event);
             } else {
                 // Cache the drag description when the operation starts, then fill it in
                 // on subsequent calls as a convenience
                 if (what == DragEvent.ACTION_DRAG_STARTED) {
+                    mCurrentDragView = null;    // Start the current-recipient tracking
                     mDragDescription = event.mClipDescription;
                 } else {
                     event.mClipDescription = mDragDescription;
@@ -2557,22 +2558,10 @@
         outLocation.y = (int) mLastTouchPoint.y;
     }
 
-    public void setDragFocus(DragEvent event, View newDragTarget) {
-        final int action = event.mAction;
-        // If we've dragged off of a view, send it the EXITED message
+    public void setDragFocus(View newDragTarget) {
         if (mCurrentDragView != newDragTarget) {
-            if (mCurrentDragView != null) {
-                event.mAction = DragEvent.ACTION_DRAG_EXITED;
-                mCurrentDragView.dispatchDragEvent(event);
-            }
             mCurrentDragView = newDragTarget;
         }
-        // If we've dragged over a new view, send it the ENTERED message
-        if (newDragTarget != null) {
-            event.mAction = DragEvent.ACTION_DRAG_ENTERED;
-            newDragTarget.dispatchDragEvent(event);
-        }
-        event.mAction = action;  // restore the event's original state
     }
 
     private AudioManager getAudioManager() {
diff --git a/core/java/android/widget/MediaController.java b/core/java/android/widget/MediaController.java
index be1234d..27a6ad3 100644
--- a/core/java/android/widget/MediaController.java
+++ b/core/java/android/widget/MediaController.java
@@ -442,7 +442,8 @@
             }
             return true;
         } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
-                || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
+                || keyCode == KeyEvent.KEYCODE_VOLUME_UP
+                || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
             // don't show the controls for volume adjustment
             return super.dispatchKeyEvent(event);
         } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 2fcae1c..81c2f65 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -6901,7 +6901,7 @@
                 // Tapping outside stops selection mode, if any
                 stopSelectionActionMode();
 
-                if (mInsertionPointCursorController != null && mText.length() > 0) {
+                if (mInsertionPointCursorController != null) {
                     mInsertionPointCursorController.show();
                 }
             }
diff --git a/core/java/android/widget/VideoView.java b/core/java/android/widget/VideoView.java
index 2be7bca..ec31dd4 100644
--- a/core/java/android/widget/VideoView.java
+++ b/core/java/android/widget/VideoView.java
@@ -515,6 +515,7 @@
         boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
                                      keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
                                      keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
+                                     keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
                                      keyCode != KeyEvent.KEYCODE_MENU &&
                                      keyCode != KeyEvent.KEYCODE_CALL &&
                                      keyCode != KeyEvent.KEYCODE_ENDCALL;
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index f4a041c..1d612e2 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -255,7 +255,6 @@
 
     private void configureTab(Tab tab, int position) {
         final TabImpl tabi = (TabImpl) tab;
-        final boolean isFirstTab = mTabs.isEmpty();
         final ActionBar.TabListener callback = tabi.getCallback();
 
         if (callback == null) {
@@ -265,26 +264,38 @@
         tabi.setPosition(position);
         mTabs.add(position, tabi);
 
-        if (isFirstTab) {
-            final FragmentTransaction trans = mActivity.getFragmentManager().openTransaction();
-            mSelectedTab = tabi;
-            callback.onTabSelected(tab, trans);
-            if (!trans.isEmpty()) {
-                trans.commit();
-            }
+        final int count = mTabs.size();
+        for (int i = position + 1; i < count; i++) {
+            mTabs.get(i).setPosition(i);
         }
     }
 
     @Override
     public void addTab(Tab tab) {
-        mActionView.addTab(tab);
-        configureTab(tab, mTabs.size());
+        addTab(tab, mTabs.isEmpty());
     }
 
     @Override
     public void addTab(Tab tab, int position) {
-        mActionView.addTab(tab, position);
+        addTab(tab, position, mTabs.isEmpty());
+    }
+
+    @Override
+    public void addTab(Tab tab, boolean setSelected) {
+        mActionView.addTab(tab, setSelected);
+        configureTab(tab, mTabs.size());
+        if (setSelected) {
+            selectTab(tab);
+        }
+    }
+
+    @Override
+    public void addTab(Tab tab, int position, boolean setSelected) {
+        mActionView.addTab(tab, position, setSelected);
         configureTab(tab, position);
+        if (setSelected) {
+            selectTab(tab);
+        }
     }
 
     @Override
diff --git a/core/java/com/android/internal/nfc/LlcpServiceSocket.java b/core/java/com/android/internal/nfc/LlcpServiceSocket.java
index 318982b..d616860 100644
--- a/core/java/com/android/internal/nfc/LlcpServiceSocket.java
+++ b/core/java/com/android/internal/nfc/LlcpServiceSocket.java
@@ -122,34 +122,6 @@
 	}
 
 	/**
-	 * Set the timeout for the accept request
-	 *
-	 * @param timeout
-	 *            value of the timeout for the accept request
-	 */
-	public void setAcceptTimeout(int timeout) {
-		try {
-			mService.setAcceptTimeout(mHandle, timeout);
-		} catch (RemoteException e) {
-			Log.e(TAG, "RemoteException in setAcceptTimeout(): ", e);
-		}
-	}
-
-	/**
-	 * Get the timeout value of the accept request
-	 *
-	 * @return mTimeout
-	 */
-	public int getAcceptTimeout() {
-		try {
-			return mService.getAcceptTimeout(mHandle);
-		} catch (RemoteException e) {
-			Log.e(TAG, "RemoteException in getAcceptTimeout(): ", e);
-			return 0;
-		}
-	}
-
-	/**
 	 * Close the created Llcp Service socket
 	 */
 	public void close() {
diff --git a/core/java/com/android/internal/nfc/LlcpSocket.java b/core/java/com/android/internal/nfc/LlcpSocket.java
index b1b1320..73c09259 100644
--- a/core/java/com/android/internal/nfc/LlcpSocket.java
+++ b/core/java/com/android/internal/nfc/LlcpSocket.java
@@ -140,34 +140,6 @@
 	}
 
 	/**
-	 * Set the timeout for the connect request
-	 *
-	 * @param timeout
-	 *            timeout value for the connect request
-	 */
-	public void setConnectTimeout(int timeout) {
-		try {
-			mService.setConnectTimeout(mHandle, timeout);
-		} catch (RemoteException e) {
-			Log.e(TAG, "RemoteException in setConnectTimeout(): ", e);
-		}
-	}
-
-	/**
-	 * Get the timeout value of the connect request
-	 *
-	 * @return mTimeout
-	 */
-	public int getConnectTimeout() {
-		try {
-			return mService.getConnectTimeout(mHandle);
-		} catch (RemoteException e) {
-			Log.e(TAG, "RemoteException in getConnectTimeout(): ", e);
-			return 0;
-		}
-	}
-
-	/**
 	 * Disconnect request to the connected LLCP socket and close the created
 	 * socket.
 	 *
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index be96e48..95d6dd3 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -123,8 +123,6 @@
         }
     };
 
-    private OnClickListener mHomeClickListener = null;
-
     private OnClickListener mTabClickListener = null;
 
     public ActionBarView(Context context, AttributeSet attrs) {
@@ -169,9 +167,6 @@
 
         mHomeLayout = new LinearLayout(context, null,
                 com.android.internal.R.attr.actionButtonStyle);
-        mHomeLayout.setClickable(true);
-        mHomeLayout.setFocusable(true);
-        mHomeLayout.setOnClickListener(mHomeClickListener);
         mHomeLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                 LayoutParams.MATCH_PARENT));
 
@@ -207,18 +202,18 @@
 
         a.recycle();
         
-        if (mLogo != null || mIcon != null || mTitle != null) {
-            mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
-            mHomeClickListener = new OnClickListener() {
-                public void onClick(View v) {
-                    Context context = getContext();
-                    if (context instanceof Activity) {
-                        Activity activity = (Activity) context;
-                        activity.onOptionsItemSelected(mLogoNavItem);
-                    }
-                }
-            };
-        }
+        mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
+        mHomeLayout.setOnClickListener(new OnClickListener() {
+          public void onClick(View v) {
+            Context context = getContext();
+            if (context instanceof Activity) {
+              Activity activity = (Activity) context;
+              activity.onOptionsItemSelected(mLogoNavItem);
+            }
+          }
+        });
+        mHomeLayout.setClickable(true);
+        mHomeLayout.setFocusable(true);
     }
 
     @Override
@@ -468,22 +463,20 @@
         return tabView;
     }
 
-    public void addTab(ActionBar.Tab tab) {
+    public void addTab(ActionBar.Tab tab, boolean setSelected) {
         ensureTabsExist();
-        final boolean isFirst = mTabLayout.getChildCount() == 0;
         View tabView = createTabView(tab);
         mTabLayout.addView(tabView);
-        if (isFirst) {
+        if (setSelected) {
             tabView.setSelected(true);
         }
     }
 
-    public void addTab(ActionBar.Tab tab, int position) {
+    public void addTab(ActionBar.Tab tab, int position, boolean setSelected) {
         ensureTabsExist();
-        final boolean isFirst = mTabLayout.getChildCount() == 0;
         final TabView tabView = createTabView(tab);
         mTabLayout.addView(tabView, position);
-        if (isFirst) {
+        if (setSelected) {
             tabView.setSelected(true);
         }
     }
diff --git a/core/res/res/layout/text_edit_no_paste_window.xml b/core/res/res/layout/text_edit_no_paste_window.xml
index 84b6103..d409d97 100644
--- a/core/res/res/layout/text_edit_no_paste_window.xml
+++ b/core/res/res/layout/text_edit_no_paste_window.xml
@@ -40,6 +40,7 @@
         android:layout_centerVertical="true"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:text="@android:string/pasteDisabled"
+        android:textColor="@android:color/dim_foreground_dark_inverse_disabled"
         android:layout_toRightOf="@id/paste_icon"
     />
 
diff --git a/core/res/res/layout/text_edit_paste_window.xml b/core/res/res/layout/text_edit_paste_window.xml
index 369f4a5..d153365 100644
--- a/core/res/res/layout/text_edit_paste_window.xml
+++ b/core/res/res/layout/text_edit_paste_window.xml
@@ -40,6 +40,7 @@
         android:layout_centerVertical="true"
         android:textAppearance="?android:attr/textAppearanceMediumInverse"
         android:text="@android:string/paste"
+        android:textColor="@android:color/black"
         android:layout_toRightOf="@id/paste_icon"
     />
 
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 79131ba..a2fa1a3 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -1145,27 +1145,28 @@
         <enum name="KEYCODE_F10" value="140" />
         <enum name="KEYCODE_F11" value="141" />
         <enum name="KEYCODE_F12" value="142" />
-        <enum name="NUM_LOCK" value="143" />
-        <enum name="NUMPAD_0" value="144" />
-        <enum name="NUMPAD_1" value="145" />
-        <enum name="NUMPAD_2" value="146" />
-        <enum name="NUMPAD_3" value="147" />
-        <enum name="NUMPAD_4" value="148" />
-        <enum name="NUMPAD_5" value="149" />
-        <enum name="NUMPAD_6" value="150" />
-        <enum name="NUMPAD_7" value="151" />
-        <enum name="NUMPAD_8" value="152" />
-        <enum name="NUMPAD_9" value="153" />
-        <enum name="NUMPAD_DIVIDE" value="154" />
-        <enum name="NUMPAD_MULTIPLY" value="155" />
-        <enum name="NUMPAD_SUBTRACT" value="156" />
-        <enum name="NUMPAD_ADD" value="157" />
-        <enum name="NUMPAD_DOT" value="158" />
-        <enum name="NUMPAD_COMMA" value="159" />
-        <enum name="NUMPAD_ENTER" value="160" />
-        <enum name="NUMPAD_EQUALS" value="161" />
-        <enum name="NUMPAD_LEFT_PAREN" value="162" />
-        <enum name="NUMPAD_RIGHT_PAREN" value="163" />
+        <enum name="KEYCODE_NUM_LOCK" value="143" />
+        <enum name="KEYCODE_NUMPAD_0" value="144" />
+        <enum name="KEYCODE_NUMPAD_1" value="145" />
+        <enum name="KEYCODE_NUMPAD_2" value="146" />
+        <enum name="KEYCODE_NUMPAD_3" value="147" />
+        <enum name="KEYCODE_NUMPAD_4" value="148" />
+        <enum name="KEYCODE_NUMPAD_5" value="149" />
+        <enum name="KEYCODE_NUMPAD_6" value="150" />
+        <enum name="KEYCODE_NUMPAD_7" value="151" />
+        <enum name="KEYCODE_NUMPAD_8" value="152" />
+        <enum name="KEYCODE_NUMPAD_9" value="153" />
+        <enum name="KEYCODE_NUMPAD_DIVIDE" value="154" />
+        <enum name="KEYCODE_NUMPAD_MULTIPLY" value="155" />
+        <enum name="KEYCODE_NUMPAD_SUBTRACT" value="156" />
+        <enum name="KEYCODE_NUMPAD_ADD" value="157" />
+        <enum name="KEYCODE_NUMPAD_DOT" value="158" />
+        <enum name="KEYCODE_NUMPAD_COMMA" value="159" />
+        <enum name="KEYCODE_NUMPAD_ENTER" value="160" />
+        <enum name="KEYCODE_NUMPAD_EQUALS" value="161" />
+        <enum name="KEYCODE_NUMPAD_LEFT_PAREN" value="162" />
+        <enum name="KEYCODE_NUMPAD_RIGHT_PAREN" value="163" />
+        <enum name="KEYCODE_VOLUME_MUTE" value="164" />
     </attr>
 
     <!-- ***************************************************************** -->
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 065c10d..1ee8271 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -1445,7 +1445,8 @@
          <code>screen</code> tag, a child of <code>compatible-screens</code>,
          which is itseld a child of the root
          {@link #AndroidManifest manifest} tag. -->
-    <declare-styleable name="AndroidManifestCompatibleScreensScreen">
+    <declare-styleable name="AndroidManifestCompatibleScreensScreen"
+                       parent="AndroidManifest.AndroidManifestCompatibleScreens">
         <!-- Specifies a compatible screen size, as per the device
              configuration screen size bins. -->
         <attr name="screenSize">
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index f905725..fd7e984 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1404,6 +1404,8 @@
   <public type="style" name="Theme.Holo.Light.Dialog" />
   <public type="style" name="Theme.Holo.Extended" />
   <public type="style" name="Theme.Holo.Light.Extended" />
+  <public type="style" name="Theme.Holo.Dialog.Alert" />
+  <public type="style" name="Theme.Holo.Light.Dialog.Alert" />
 
   <public type="style" name="Widget.ListPopupWindow" />
   <public type="style" name="Widget.PopupMenu" />
diff --git a/data/keyboards/Generic.kl b/data/keyboards/Generic.kl
index 818397b..e98000d 100644
--- a/data/keyboards/Generic.kl
+++ b/data/keyboards/Generic.kl
@@ -132,7 +132,7 @@
 key 110   INSERT
 key 111   FORWARD_DEL
 # key 112 "KEY_MACRO"
-key 113   MUTE
+key 113   VOLUME_MUTE
 key 114   VOLUME_DOWN
 key 115   VOLUME_UP
 key 116   POWER             WAKE
diff --git a/data/keyboards/Motorola_Bluetooth_Wireless_Keyboard.kl b/data/keyboards/Motorola_Bluetooth_Wireless_Keyboard.kl
index 1298d53..eab78a0 100644
--- a/data/keyboards/Motorola_Bluetooth_Wireless_Keyboard.kl
+++ b/data/keyboards/Motorola_Bluetooth_Wireless_Keyboard.kl
@@ -83,9 +83,10 @@
 key 105   DPAD_LEFT
 key 106   DPAD_RIGHT
 key 107   MOVE_END
+key 108   DPAD_DOWN
 key 110   INSERT
 key 111   FORWARD_DEL
-key 113   MUTE
+key 113   VOLUME_MUTE
 key 114   VOLUME_DOWN
 key 115   VOLUME_UP
 key 125   MENU
diff --git a/docs/html/guide/appendix/market-filters.jd b/docs/html/guide/appendix/market-filters.jd
index e74cefb..6ca8acc 100644
--- a/docs/html/guide/appendix/market-filters.jd
+++ b/docs/html/guide/appendix/market-filters.jd
@@ -1,322 +1,353 @@
-page.title=Market Filters

-@jd:body

-

-<div id="qv-wrapper">

-<div id="qv">

-

-<h2>Quickview</h2>

-<ul> <li>Android Market applies filters to that let you control whether your app is shown to a

-user who is browing or searching for apps.</li> 

-<li>Filtering is determined by elements in an app's manifest file,

-aspects of the device being used, and other factors.</li> </ul>

-

-<h2>In this document</h2>

-

-<ol> <li><a href="#how-filters-work">How Filters Work in Android Market</a></li>

-<li><a href="#manifest-filters">Filtering based on Manifest File Elements</a></li>

-<li><a href="#other-filters">Other Filters</a></li> 

-</ol>

-

-<h2>See also</h2>

- <ol> 

-<li><a

-href="{@docRoot}guide/practices/compatibility.html">Compatibility</a></li>

-<li style="margin-top:2px;"><code><a

-href="{@docRoot}guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></code></li>

-<li><code><a

-href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></code></li>

-<li><code><a

-href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></code></li>

-<li><code><a

-href="{@docRoot}guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></code></li>

-<li><code><a

-href="{@docRoot}guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></code></li>

-<li><code><a

-href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</code></a></li>

-</ol>

-

-<div id="qv-extra"> <img id="rule" src="{@docRoot}assets/images/grad-rule-qv.png">

-<div id="qv-sub-rule"> <img src="{@docRoot}assets/images/icon_market.jpg"

-style="float:left;margin:0;padding:0;"> <p style="color:#669999;">Interested in

-publishing your app on Android Market?</p> <a id="publish-link"

-href="http://market.android.com/publish">Go to Android Market &raquo;</a> </div>

-</div>

-

-</div> </div>

-

-<p>When a user searches or browses in Android Market, the results are filtered, and

-some applications might not be visible. For example, if an application requires a

-trackball (as specified in the manifest file), then Android Market will not show

-the app on any device that does not have a trackball.</p> <p>The manifest file and

-the device's hardware and features are only part of how applications are filtered

-&#8212; filtering also depends on the country and carrier, the presence or absence

-of a SIM card, and other factors. </p>

-

-<p>Changes to the Android Market filters are independent of changes 

-to the Android platform itself. This document will be updated periodically to reflect 

-any changes that occur. </p>

-

-<h2 id="how-filters-work">How Filters Work in Android Market</h2>

-

-<p>Android Market uses the filter restrictions described below to determine

-whether to show your application to a user who is browsing or searching for

-applications on a given device. When determining whether to display your app,

-Market checks the device's hardware and software capabilities, as well as it's

-carrier, location, and other characteristics. It then compares those against the

-restrictions and dependencies expressed by the application itself, in its

-manifest, <code>.apk</code>, and publishing details. If the application is

-compatible with the device according to the filter rules, Market displays the

-application to the user. Otherwise, Market hides your application from search

-results and category browsing. </p>

-

-<p> You can use the filters described below to control whether Market shows or

-hides your application to users. You can request any combination of the

-available filters for your app &#8212; for example, you could set a

-<code>minSdkVersion</code> requirement of <code>"4"</code> and set

-<code>smallScreens="false"</code> in the app, then when uploading the app to

-Market you could target European countries (carriers) only. Android Market's

-filters would prevent the application from being visible on any device that did

-not match all three of these requirements. </p>

-

- <p>A filtered app is not visible within Market, even if a user specifically requests 

-the app by clicking a deep link that points directly to the app's ID within Market. 

-All filtering restrictions are associated with an application's version and can

-change between versions. For example:</p> 

-

-<ul> 

-<li>If you publish a new version of your app with stricter restrictions, the app

-will not be visible to users for whom it is filtered, even if those users were

-able see the previous version.</li>

-<li>If a user has installed your application and you publish an upgrade that

-makes the app invisible to the user, the user will not see that an upgrade is

-available. </li>

-</ul>

-

-<h2 id="manifest-filters">Filtering based on Manifest Elements</h2>

-

-<p>Most Market filters are triggered by elements within an application's

-manifest file, <a

-href="{@docRoot}guide/topics/manifest/manifest-intro.html">AndroidManifest.xml</a>,

-although not everything in the manifest file can trigger filtering. The

-table below lists the manifest elements that you can use to trigger Android

-Market filtering, and explains how the filtering works.</p>

-

-<p class="table-caption"><strong>Table 1.</strong> Manifest elements that

-trigger filtering on Market.</p>

-<table>

-  <tr>

-    <th>Manifest Element</th>

-    <th>Filter Name</th>

-    <th>How It Works</th>

-  </tr>

-  <tr>

-    <td valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></code>

-      <!-- ##api level 4## --></td>

-    <td valign="top">Screen Size</td>

-    <td valign="top">

-

-<p>An application indicates the screen sizes that it is capable of supporting by

-setting attributes of the <code>&lt;supports-screens&gt;</code> element. When

-the application is published, Market uses those attributes to determine whether

-to show the application to users, based on the screen sizes of their

-devices. </p>

-

-<p>As a general rule, Market assumes that the platform on the device can adapt

-smaller layouts to larger screens, but cannot adapt larger layouts to smaller

-screens. Thus, if an application declares support for "normal" screen size only,

-Market makes the application available to both normal- and large-screen devices,

-but filters the application so that it is not available to small-screen

-devices.</p>

-

-<p>If an application does not declare attributes for

-<code>&lt;supports-screens&gt;</code>, Market uses the default values for those

-attributes, which vary by API Level. Specifically: </p>

-

-<ul>

-<li><p>In API level 3, the <code>&lt;supports-screens&gt;</code> element itself

-is undefined and no attributes are available. In this case, Market assumes that

-the application is designed for normal-size screens and shows the application to

-devices that have normal or large screens. </p>

-

-<p>This behavior is especially significant for applications that set their

-<code><a

-href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">android:

-minSdkVersion</a></code> to 3 or lower, since Market will filter them from

-small-screen devices by default. Such applications can enable support for

-small-screen devices by adding a <code>android:targetSdkVersion="4"</code>

-attribute to the <code>&lt;uses-sdk&gt;</code> element in their manifest

-files. For more information, see <a

-href="{@docRoot}guide/practices/screens_support.html#strategies">Strategies for

-Legacy Applications</a>.</p></li>

-

-<li>In API Level 4, the defaults for all of the attributes is

-<code>"true"</code>. If an application does not declare a

-<code>&lt;supports-screens&gt;</code> element, Market assumes that the

-application is designed for all screen sizes and does not filter it from any

-devices. If the application does not declare one of the attributes, Market uses

-the default value of <code>"true"</code> and does not filter the app for devices

-of corresponding screen size.</li>

-</ul>

-

-    <p><strong>Example 1</strong><br />

-    The manifest declares <code>&lt;uses-sdk android:minSdkVersion="3"&gt;</code>

-    and does not does not include a <code>&lt;supports-screens&gt;</code> element.

-    <strong>Result</strong>: Android Market will not show the app to a user of a

-    small-screen device, but will show it to users of normal and large-screen

-    devices,  users, unless  other filters apply. </p>

-    <p><strong>Example 2<br />

-    </strong>The manifest declares <code>&lt;uses-sdk android:minSdkVersion="3"

-    android:targetSdkVersion="4"&gt;</code> and does not include a

-    <code>&lt;supports-screens&gt;</code> element.

-    <strong>Result</strong>: Android Market will show the app to users on all 

-    devices, unless other filters apply. </p>

-    <p><strong>Example 3<br />

-    </strong>The manifest declares <code>&lt;uses-sdk android:minSdkVersion="4"&gt;</code>

-    and does not include a <code>&lt;supports-screens&gt;</code> element.

-    <strong>Result</strong>: Android Market will show the app to all users,

-    unless  other filters apply. </p>

-    <p>For more information on how to declare support for screen sizes in your

-    application, see <code><a

-    href="{@docRoot}guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></code>

-    and <a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple

-    Screens</a>.</p>

-</td>

-  </tr>

-  <tr>

-    <td valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></code>

-      <!-- ##api level 3## --></td>

-    <td valign="top">Device

-    Configuration: <br />

-    keyboard, navigation, touch screen</td>

-    <td valign="top"><p>An application can

-    request certain hardware features, and Android Market will  show the app only on devices that have the required hardware.</p>

-      <p><strong>Example 1<br />

-      </strong>The manifest includes <code>&lt;uses-configuration android:reqFiveWayNav=&quot;true&quot; /&gt;</code>, and a user is searching for apps on a device that does not have a five-way navigational control. <strong>Result</strong>: Android Market will not show the app to the user. </p>

-      <p><strong>Example 2<br />

-      </strong>The manifest does not include a <code>&lt;uses-configuration&gt;</code> element. <strong>Result</strong>: Android Market will show the app to all users, unless other filters apply.</p>

-<p>For more details, see  <a

-href="{@docRoot}guide/topics/manifest/uses-configuration-element.html"><code>&lt;uses-configuration&gt;</code></a>.</p></td>

-  </tr>

-  <tr>

-    <td rowspan="2" valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></code>

-      <!-- ##api level 4## --></td>

-    <td valign="top">Device Features<br />

-      (<code>name</code>)</td>

-    <td valign="top"><p>An

-      application can require certain device features to be present on the device. This functionality

-      was introduced in Android 2.0 (API Level 5).</p>

-      <p><strong>Example 1<br />

-      </strong>The manifest includes <code>&lt;uses-feature android:name=&quot;android.hardware.sensor.light&quot; /&gt;</code>, and a user is searching for apps on a device that does not have a light sensor. <strong>Result</strong>: Android Market will not show the app to the user. </p>

-      <p><strong>Example 2<br />

-      </strong>The manifest does not include a <code>&lt;uses-feature&gt;</code> element. <strong>Result</strong>: Android Market will show the app to all users, unless other filters apply.</p>

-      <p>For more details, see <code><a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></code>.</p>

-<p><em>A note about camera:</em> If an

-        application requests the CAMERA permission using the <a

-href="{@docRoot}guide/topics/manifest/uses-permission-element.html"> <code>&lt;uses-permission&gt;</code></a> element, Market assumes that the

-        application requires the camera and all camera features (such as autofocus). For applications that require the camera and are designed to run on Android 1.5 (API Level 3), declaring the CAMERA permission is an effective way of ensuring that Market filters your app properly, since <code>uses-feature</code> filtering is not available to applications compiled against the Android 1.5 platform. For more details about requiring or requesting a camera, see the <a href="{@docRoot}guide/topics/manifest/uses-library-element.html#required"> <code>required</code></a> attribute of <code>&lt;uses-feature&gt;</code>. </p></td>

-  </tr>

-  <tr>

-    <td valign="top">OpenGL-ES

-    Version<br />

-(<code>openGlEsVersion</code>)</td>

-    <td valign="top"><p>An application can require that the device support a specific

-      OpenGL-ES version using the <code>&lt;uses-feature

-        android:openGlEsVersion=&quot;int&quot;&gt;</code> attribute.</p>

-      <p><strong>Example 1<br />

-      </strong>An app

-        requests multiple OpenGL-ES versions by specifying <code>openGlEsVersion</code> multiple times in the

-        manifest.  <strong>Result</strong>: Market assumes that the app requires the highest of the indicated versions.</p>

-<p><strong>Example 2<br />

-</strong>An app

-        requests OpenGL-ES version 1.1, and a user is searching for apps on a device that supports OpenGL-ES version 2.0. <strong>Result</strong>: Android Market will show the app to the user, unless other filters apply. If a

-  device reports that it supports OpenGL-ES version <em>X</em>,  Market assumes that it

-  also supports any version earlier than <em>X</em>.

-</p>

-<p><strong>Example 3<br />

-</strong>A user is searching for apps on a device that does not

-        report an OpenGL-ES version (for example, a device running Android 1.5 or earlier). <strong>Result</strong>: Android Market assumes that the device

-  supports only OpenGL-ES 1.0. Market will only show the user apps that do not specify <code>openGlEsVersion</code>, or apps that do not specify an OpenGL-ES version higher than 1.0. </p>

-      <p><strong>Example 4<br />

-      </strong>The manifest does not specify <code>openGlEsVersion</code>. <strong>Result</strong>: Android Market will show the app to all users, unless other filters apply. </p>

-<p>For more details, see <a

-href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><code>&lt;uses-feature&gt;</code></a>.</p></td>

-  </tr>

-  <tr>

-    <td valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></code></td>

-    <td valign="top">Software Libraries</td>

-    <td valign="top"><p>An application can require specific

-    shared libraries to be present on the device. </p>

-      <p><strong>Example 1<br />

-      </strong>An app requires the <code>com.google.android.maps</code> library, and a user is searching for apps on a device that does not have the <code>com.google.android.maps</code> library. <strong>Result</strong>: Android Market will not show the app to the user. </p>

-      <p><strong>Example 2</strong><br />

-        The manifest does not include a <code>&lt;uses-library&gt;</code> element. <strong>Result</strong>: Android Market will show the app to all users, unless other filters apply.</p>

-<p>For more details, see <a

-href="{@docRoot}guide/topics/manifest/uses-library-element.html"><code>&lt;uses-library&gt;</code></a>.</p></td>

-  </tr>

-  <tr>

-    <td valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></code></td>

-    <td valign="top">&nbsp;</td>

-    <td valign="top"><em>(See the note in the description of <code>&lt;uses-feature&gt;</code>, above.)</em></td>

-  </tr>

-  <tr>

-    <td rowspan="2" valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></code></td>

-    <td valign="top">Minimum Framework Version (<code>minSdkVersion</code>)</td>

-    <td valign="top"><p>An application can require a minimum API level.  </p>

-      <p><strong>Example 1</strong><br />

-        The manifest includes <code>&lt;uses-sdk

-      android:minSdkVersion=&quot;3&quot;&gt;</code>, and the app uses APIs that were introduced in API Level 3. A user is searching for apps on a device that has API Level 2. <strong>Result</strong>: Android Market will not show the app to the user. </p>

-      <p><strong>Example 2</strong><br />

-      The manifest does not include <code>minSdkVersion</code>, and the app uses APIs that were introduced in API Level 3. A user is searching for apps on a device that has API Level 2. <strong>Result</strong>: Android Market assumes that <code>minSdkVersion</code> is &quot;1&quot; and that the app is compatible with all versions of Android. Market  shows the app to the user and allows the user to download the app. The app crashes at runtime. </p>

-    <p>Because you want to avoid this second scenario, we recommend that you always declare a <code>minSdkVersion</code>. For details, see <a

-href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min"><code>android:minSdkVersion</code></a>.</p></td>

-  </tr>

-  <tr>

-    <td valign="top">Maximum Framework Version (<code>maxSdkVersion</code>)</td>

-    <td valign="top"><p><em>Deprecated.</em> Android

-    2.1 and later do not check or enforce the <code>maxSdkVersion</code> attribute, and

-    the SDK will not compile if <code>maxSdkVersion</code> is set in an app's manifest. For devices already

-    compiled with <code>maxSdkVersion</code>, Market will respect it and use it for

-    filtering.</p>

-<p> Declaring <code>maxSdkVersion</code> is <em>not</em> recommended. For details, see <a

-href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#max"><code>android:maxSdkVersion</code></a>.</p></td>

-  </tr>

-</table>

-

-<h2 id="other-filters">Other Filters</h2>

-<p>Android Market uses other application characteristics to determine whether to show or hide an application for a particular user on a given device, as described in the table below. </p>

-

-<p class="table-caption"><strong>Table 2.</strong> Application and publishing characteristics that affect filtering on Market.</p>

-<table> <tr>

-    <th>Filter Name</th> <th>How It Works</th> </tr>

-

-  <tr>

-    <td valign="top">Publishing Status</td> <td valign="top"><p>Only published applications will appear in

-      searches and browsing within Android Market.</p> <p>Even if an app is unpublished, it can

-        be installed if users can see it in their Downloads area among their purchased,

-        installed, or recently uninstalled apps.</p> <p>If an application has been

-  suspended, users will not be able to reinstall or update it, even if it appears in their Downloads.</p> </td></tr>

-  <tr>

-  <td valign="top">Priced

-    Status</td> <td valign="top"><p>Not all users can see paid apps. To show paid apps, a device

-must have a SIM card and be running Android 1.1 or later, and it must be in a

-country (as determined by SIM carrier) in which paid apps are available.</p></td>

-</tr> <tr>

-  <td valign="top">Country / Carrier Targeting</td> <td valign="top"> <p>When you upload your app to

-    the Android Market, you can select specific countries to target. The app will only

-    be visible to the countries (carriers) that you select, as follows:</p>

-    <ul><li><p>A device's country is determined based on the carrier, if a carrier is

-      available. If no carrier can be determined, the Market application tries to

-      determine the country based on IP.</p></li> <li><p>Carrier is determined based on

-      the device's SIM (for GSM devices), not the current roaming carrier.</p></li></ul>

-</td> </tr> <tr>

-  <td valign="top">Native Platform</td> <td valign="top"><p>An application that includes native

-    libraries that target a specific platform (ARM EABI v7, for example) will only be

-    visible on devices that support that platform. For details about the NDK and using

-    native libraries, see <a href="{@docRoot}sdk/ndk/index.html#overview">What is the

-      Android NDK?</a></p> </tr> <tr>

-        <td valign="top">Forward-Locked Applications</td> <td valign="top"><p>To

-          forward lock an application, set copy protection to "On" when you upload the

-          application to Market. Market will not show copy-protected applications on

-developer devices or unreleased devices.</p></td> </tr> </table>

-

-

+page.title=Market Filters
+@jd:body
+
+<div id="qv-wrapper">
+<div id="qv">
+
+<h2>Quickview</h2>
+<ul> <li>Android Market applies filters to that let you control whether your app is shown to a
+user who is browing or searching for apps.</li> 
+<li>Filtering is determined by elements in an app's manifest file,
+aspects of the device being used, and other factors.</li> </ul>
+
+<h2>In this document</h2>
+
+<ol> <li><a href="#how-filters-work">How Filters Work in Android Market</a></li>
+<li><a href="#manifest-filters">Filtering based on Manifest File Elements</a></li>
+<li><a href="#other-filters">Other Filters</a></li> 
+</ol>
+
+<h2>See also</h2>
+ <ol> 
+<li><a
+href="{@docRoot}guide/practices/compatibility.html">Compatibility</a></li>
+<li style="margin-top:2px;"><code><a
+href="{@docRoot}guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></code></li>
+<li><code><a
+href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></code></li>
+<li><code><a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></code></li>
+<li><code><a
+href="{@docRoot}guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></code></li>
+<li><code><a
+href="{@docRoot}guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></code></li>
+<li><code><a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</code></a></li>
+</ol>
+
+<div id="qv-extra"> <img id="rule" src="{@docRoot}assets/images/grad-rule-qv.png">
+<div id="qv-sub-rule"> <img src="{@docRoot}assets/images/icon_market.jpg"
+style="float:left;margin:0;padding:0;"> <p style="color:#669999;">Interested in
+publishing your app on Android Market?</p> <a id="publish-link"
+href="http://market.android.com/publish">Go to Android Market &raquo;</a> </div>
+</div>
+
+</div> </div>
+
+<p>When a user searches or browses in Android Market, the results are filtered, and
+some applications might not be visible. For example, if an application requires a
+trackball (as specified in the manifest file), then Android Market will not show
+the app on any device that does not have a trackball.</p> <p>The manifest file and
+the device's hardware and features are only part of how applications are filtered
+&#8212; filtering also depends on the country and carrier, the presence or absence
+of a SIM card, and other factors. </p>
+
+<p>Changes to the Android Market filters are independent of changes 
+to the Android platform itself. This document will be updated periodically to reflect 
+any changes that occur. </p>
+
+<h2 id="how-filters-work">How Filters Work in Android Market</h2>
+
+<p>Android Market uses the filter restrictions described below to determine
+whether to show your application to a user who is browsing or searching for
+applications on a given device. When determining whether to display your app,
+Market checks the device's hardware and software capabilities, as well as it's
+carrier, location, and other characteristics. It then compares those against the
+restrictions and dependencies expressed by the application itself, in its
+manifest, <code>.apk</code>, and publishing details. If the application is
+compatible with the device according to the filter rules, Market displays the
+application to the user. Otherwise, Market hides your application from search
+results and category browsing. </p>
+
+<p> You can use the filters described below to control whether Market shows or
+hides your application to users. You can request any combination of the
+available filters for your app &#8212; for example, you could set a
+<code>minSdkVersion</code> requirement of <code>"4"</code> and set
+<code>smallScreens="false"</code> in the app, then when uploading the app to
+Market you could target European countries (carriers) only. Android Market's
+filters would prevent the application from being visible on any device that did
+not match all three of these requirements. </p>
+
+ <p>A filtered app is not visible within Market, even if a user specifically requests 
+the app by clicking a deep link that points directly to the app's ID within Market. 
+All filtering restrictions are associated with an application's version and can
+change between versions. For example:</p> 
+
+<ul> 
+<li>If you publish a new version of your app with stricter restrictions, the app
+will not be visible to users for whom it is filtered, even if those users were
+able see the previous version.</li>
+<li>If a user has installed your application and you publish an upgrade that
+makes the app invisible to the user, the user will not see that an upgrade is
+available. </li>
+</ul>
+
+<h2 id="manifest-filters">Filtering based on Manifest Elements</h2>
+
+<p>Most Market filters are triggered by elements within an application's
+manifest file, <a
+href="{@docRoot}guide/topics/manifest/manifest-intro.html">AndroidManifest.xml</a>,
+although not everything in the manifest file can trigger filtering. The
+table below lists the manifest elements that you can use to trigger Android
+Market filtering, and explains how the filtering works.</p>
+
+<p class="table-caption"><strong>Table 1.</strong> Manifest elements that
+trigger filtering on Market.</p>
+<table>
+  <tr>
+    <th>Manifest Element</th>
+    <th>Filter Name</th>
+    <th>How It Works</th>
+  </tr>
+  <tr>
+    <td valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></code>
+      <!-- ##api level 4## --></td>
+    <td valign="top">Screen Size</td>
+    <td valign="top">
+
+<p>An application indicates the screen sizes that it is capable of supporting by
+setting attributes of the <code>&lt;supports-screens&gt;</code> element. When
+the application is published, Market uses those attributes to determine whether
+to show the application to users, based on the screen sizes of their
+devices. </p>
+
+<p>As a general rule, Market assumes that the platform on the device can adapt
+smaller layouts to larger screens, but cannot adapt larger layouts to smaller
+screens. Thus, if an application declares support for "normal" screen size only,
+Market makes the application available to both normal- and large-screen devices,
+but filters the application so that it is not available to small-screen
+devices.</p>
+
+<p>If an application does not declare attributes for
+<code>&lt;supports-screens&gt;</code>, Market uses the default values for those
+attributes, which vary by API Level. Specifically: </p>
+
+<ul>
+<li><p>In API level 3, the <code>&lt;supports-screens&gt;</code> element itself
+is undefined and no attributes are available. In this case, Market assumes that
+the application is designed for normal-size screens and shows the application to
+devices that have normal or large screens. </p>
+
+<p>This behavior is especially significant for applications that set their
+<code><a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">android:
+minSdkVersion</a></code> to 3 or lower, since Market will filter them from
+small-screen devices by default. Such applications can enable support for
+small-screen devices by adding a <code>android:targetSdkVersion="4"</code>
+attribute to the <code>&lt;uses-sdk&gt;</code> element in their manifest
+files. For more information, see <a
+href="{@docRoot}guide/practices/screens_support.html#strategies">Strategies for
+Legacy Applications</a>.</p></li>
+
+<li>In API Level 4, the defaults for all of the attributes is
+<code>"true"</code>. If an application does not declare a
+<code>&lt;supports-screens&gt;</code> element, Market assumes that the
+application is designed for all screen sizes and does not filter it from any
+devices. If the application does not declare one of the attributes, Market uses
+the default value of <code>"true"</code> and does not filter the app for devices
+of corresponding screen size.</li>
+</ul>
+
+    <p><strong>Example 1</strong><br />
+    The manifest declares <code>&lt;uses-sdk android:minSdkVersion="3"&gt;</code>
+    and does not does not include a <code>&lt;supports-screens&gt;</code> element.
+    <strong>Result</strong>: Android Market will not show the app to a user of a
+    small-screen device, but will show it to users of normal and large-screen
+    devices,  users, unless  other filters apply. </p>
+    <p><strong>Example 2<br />
+    </strong>The manifest declares <code>&lt;uses-sdk android:minSdkVersion="3"
+    android:targetSdkVersion="4"&gt;</code> and does not include a
+    <code>&lt;supports-screens&gt;</code> element.
+    <strong>Result</strong>: Android Market will show the app to users on all 
+    devices, unless other filters apply. </p>
+    <p><strong>Example 3<br />
+    </strong>The manifest declares <code>&lt;uses-sdk android:minSdkVersion="4"&gt;</code>
+    and does not include a <code>&lt;supports-screens&gt;</code> element.
+    <strong>Result</strong>: Android Market will show the app to all users,
+    unless  other filters apply. </p>
+    <p>For more information on how to declare support for screen sizes in your
+    application, see <code><a
+    href="{@docRoot}guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></code>
+    and <a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
+    Screens</a>.</p>
+</td>
+  </tr>
+  <tr>
+    <td valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></code>
+      <!-- ##api level 3## --></td>
+    <td valign="top">Device
+    Configuration: <br />
+    keyboard, navigation, touch screen</td>
+    <td valign="top"><p>An application can
+    request certain hardware features, and Android Market will  show the app only on devices that have the required hardware.</p>
+      <p><strong>Example 1<br />
+      </strong>The manifest includes <code>&lt;uses-configuration android:reqFiveWayNav=&quot;true&quot; /&gt;</code>, and a user is searching for apps on a device that does not have a five-way navigational control. <strong>Result</strong>: Android Market will not show the app to the user. </p>
+      <p><strong>Example 2<br />
+      </strong>The manifest does not include a <code>&lt;uses-configuration&gt;</code> element. <strong>Result</strong>: Android Market will show the app to all users, unless other filters apply.</p>
+<p>For more details, see  <a
+href="{@docRoot}guide/topics/manifest/uses-configuration-element.html"><code>&lt;uses-configuration&gt;</code></a>.</p></td>
+  </tr>
+  <tr>
+    <td rowspan="2" valign="top" style="white-space:nowrap;"><code><a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a>
+</code>
+      <!-- ##api level 4## --></td>
+    <td valign="top">Device Features<br />
+      (<code>name</code>)</td>
+    <td valign="top"><p>An application can require certain device features to be
+present on the device. This functionality was introduced in Android 2.0 (API
+Level 5).</p>
+      <p><strong>Example 1<br />
+      </strong>The manifest includes <code>&lt;uses-feature
+android:name=&quot;android.hardware.sensor.light&quot; /&gt;</code>, and a user
+is searching for apps on a device that does not have a light sensor.
+<strong>Result</strong>: Android Market will not show the app to the user. </p>
+      <p><strong>Example 2<br />
+      </strong>The manifest does not include a <code>&lt;uses-feature&gt;</code>
+element. <strong>Result</strong>: Android Market will show the app to all users,
+unless other filters apply.</p>
+      <p>For complete information, see <code><a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a>
+</code>.</p>
+      <p><em>Filtering based on implied features:</em> In some cases, Android
+Market interprets permissions requested through
+<code>&lt;uses-permission&gt;</code> elements as feature requirements equivalent
+to those declared in <code>&lt;uses-feature&gt;</code> elements. See <a
+href="#uses-permission-filtering"><code>&lt;uses-permission&gt;</code></a>,
+below.</p>
+</td>
+  </tr>
+  <tr>
+    <td valign="top">OpenGL-ES
+    Version<br />
+(<code>openGlEsVersion</code>)</td>
+    <td valign="top"><p>An application can require that the device support a specific
+      OpenGL-ES version using the <code>&lt;uses-feature
+        android:openGlEsVersion=&quot;int&quot;&gt;</code> attribute.</p>
+      <p><strong>Example 1<br />
+      </strong>An app
+        requests multiple OpenGL-ES versions by specifying <code>openGlEsVersion</code> multiple times in the
+        manifest.  <strong>Result</strong>: Market assumes that the app requires the highest of the indicated versions.</p>
+<p><strong>Example 2<br />
+</strong>An app
+        requests OpenGL-ES version 1.1, and a user is searching for apps on a device that supports OpenGL-ES version 2.0. <strong>Result</strong>: Android Market will show the app to the user, unless other filters apply. If a
+  device reports that it supports OpenGL-ES version <em>X</em>,  Market assumes that it
+  also supports any version earlier than <em>X</em>.
+</p>
+<p><strong>Example 3<br />
+</strong>A user is searching for apps on a device that does not
+        report an OpenGL-ES version (for example, a device running Android 1.5 or earlier). <strong>Result</strong>: Android Market assumes that the device
+  supports only OpenGL-ES 1.0. Market will only show the user apps that do not specify <code>openGlEsVersion</code>, or apps that do not specify an OpenGL-ES version higher than 1.0. </p>
+      <p><strong>Example 4<br />
+      </strong>The manifest does not specify <code>openGlEsVersion</code>. <strong>Result</strong>: Android Market will show the app to all users, unless other filters apply. </p>
+<p>For more details, see <a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><code>&lt;uses-feature&gt;</code></a>.</p></td>
+  </tr>
+  <tr>
+    <td valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></code></td>
+    <td valign="top">Software Libraries</td>
+    <td valign="top"><p>An application can require specific
+    shared libraries to be present on the device. </p>
+      <p><strong>Example 1<br />
+      </strong>An app requires the <code>com.google.android.maps</code> library, and a user is searching for apps on a device that does not have the <code>com.google.android.maps</code> library. <strong>Result</strong>: Android Market will not show the app to the user. </p>
+      <p><strong>Example 2</strong><br />
+        The manifest does not include a <code>&lt;uses-library&gt;</code> element. <strong>Result</strong>: Android Market will show the app to all users, unless other filters apply.</p>
+<p>For more details, see <a
+href="{@docRoot}guide/topics/manifest/uses-library-element.html"><code>&lt;uses-library&gt;</code></a>.</p></td>
+  </tr>
+  <tr id="uses-permission-filtering">
+    <td valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></code></td>
+    <td valign="top">&nbsp;</td>
+    <td valign="top">Strictly, Android Market does not filter based on
+<code>&lt;uses-permission&gt;</code> elements. However, it does read the
+elements to determine whether the application has hardware feature requirements
+that may not have been properly declared in <code>&lt;uses-feature&gt;</code>
+elements. For example, if an application requests the <code>CAMERA</code>
+permission but does not declare a <code>&lt;uses-feature&gt;</code> element for
+<code>android.hardware.camera</code>, Android Market considers that the
+application requires a camera and should not be shown to users whose devices do
+not offer a camera.</p>
+    <p>In general, if an application requests hardware-related permissions,
+Android Market assumes that the application requires the underlying hardware
+features, even though there might be no corresponding to
+<code>&lt;uses-feature&gt;</code> declarations. Android Market then sets up
+filtering based on the features implied by the <code>&lt;uses-feature&gt;</code>
+declarations.</p>
+    <p>For a list of permissions that imply hardware features, see
+the documentation for the <a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions-features"><code>&lt;uses-feature&gt;</code></a>
+element.</p>
+</td>
+  </tr>
+  <tr>
+    <td rowspan="2" valign="top" style="white-space:nowrap;"><code><a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></code></td>
+    <td valign="top">Minimum Framework Version (<code>minSdkVersion</code>)</td>
+    <td valign="top"><p>An application can require a minimum API level.  </p>
+      <p><strong>Example 1</strong><br />
+        The manifest includes <code>&lt;uses-sdk
+      android:minSdkVersion=&quot;3&quot;&gt;</code>, and the app uses APIs that were introduced in API Level 3. A user is searching for apps on a device that has API Level 2. <strong>Result</strong>: Android Market will not show the app to the user. </p>
+      <p><strong>Example 2</strong><br />
+      The manifest does not include <code>minSdkVersion</code>, and the app uses APIs that were introduced in API Level 3. A user is searching for apps on a device that has API Level 2. <strong>Result</strong>: Android Market assumes that <code>minSdkVersion</code> is &quot;1&quot; and that the app is compatible with all versions of Android. Market  shows the app to the user and allows the user to download the app. The app crashes at runtime. </p>
+    <p>Because you want to avoid this second scenario, we recommend that you always declare a <code>minSdkVersion</code>. For details, see <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min"><code>android:minSdkVersion</code></a>.</p></td>
+  </tr>
+  <tr>
+    <td valign="top">Maximum Framework Version (<code>maxSdkVersion</code>)</td>
+    <td valign="top"><p><em>Deprecated.</em> Android
+    2.1 and later do not check or enforce the <code>maxSdkVersion</code> attribute, and
+    the SDK will not compile if <code>maxSdkVersion</code> is set in an app's manifest. For devices already
+    compiled with <code>maxSdkVersion</code>, Market will respect it and use it for
+    filtering.</p>
+<p> Declaring <code>maxSdkVersion</code> is <em>not</em> recommended. For details, see <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#max"><code>android:maxSdkVersion</code></a>.</p></td>
+  </tr>
+</table>
+
+<h2 id="other-filters">Other Filters</h2>
+<p>Android Market uses other application characteristics to determine whether to show or hide an application for a particular user on a given device, as described in the table below. </p>
+
+<p class="table-caption"><strong>Table 2.</strong> Application and publishing characteristics that affect filtering on Market.</p>
+<table> <tr>
+    <th>Filter Name</th> <th>How It Works</th> </tr>
+
+  <tr>
+    <td valign="top">Publishing Status</td> <td valign="top"><p>Only published applications will appear in
+      searches and browsing within Android Market.</p> <p>Even if an app is unpublished, it can
+        be installed if users can see it in their Downloads area among their purchased,
+        installed, or recently uninstalled apps.</p> <p>If an application has been
+  suspended, users will not be able to reinstall or update it, even if it appears in their Downloads.</p> </td></tr>
+  <tr>
+  <td valign="top">Priced
+    Status</td> <td valign="top"><p>Not all users can see paid apps. To show paid apps, a device
+must have a SIM card and be running Android 1.1 or later, and it must be in a
+country (as determined by SIM carrier) in which paid apps are available.</p></td>
+</tr> <tr>
+  <td valign="top">Country / Carrier Targeting</td> <td valign="top"> <p>When you upload your app to
+    the Android Market, you can select specific countries to target. The app will only
+    be visible to the countries (carriers) that you select, as follows:</p>
+    <ul><li><p>A device's country is determined based on the carrier, if a carrier is
+      available. If no carrier can be determined, the Market application tries to
+      determine the country based on IP.</p></li> <li><p>Carrier is determined based on
+      the device's SIM (for GSM devices), not the current roaming carrier.</p></li></ul>
+</td> </tr> <tr>
+  <td valign="top">Native Platform</td> <td valign="top"><p>An application that includes native
+    libraries that target a specific platform (ARM EABI v7, for example) will only be
+    visible on devices that support that platform. For details about the NDK and using
+    native libraries, see <a href="{@docRoot}sdk/ndk/index.html#overview">What is the
+      Android NDK?</a></p> </tr> <tr>
+        <td valign="top">Forward-Locked Applications</td> <td valign="top"><p>To
+          forward lock an application, set copy protection to "On" when you upload the
+          application to Market. Market will not show copy-protected applications on
+developer devices or unreleased devices.</p></td> </tr> </table>
+
+
diff --git a/docs/html/guide/developing/eclipse-adt.jd b/docs/html/guide/developing/eclipse-adt.jd
index d0fc9b8..1594159 100644
--- a/docs/html/guide/developing/eclipse-adt.jd
+++ b/docs/html/guide/developing/eclipse-adt.jd
@@ -392,11 +392,11 @@
 
 <ul>
 <li>If you are developing multiple related applications that use some of the
-same components, you move the redundant components out of their respective
+same components, you could move the redundant components out of their respective
 application projects and create a single, reuseable set of the same components
 in a library project. </li>
 <li>If you are creating an application that exists in both free and paid
-versions. You move the part of the application that is common to both versions
+versions, you could move the part of the application that is common to both versions
 into a library project. The two dependent projects, with their different package
 names, will reference the library project and provide only the difference
 between the two application versions.</li>
diff --git a/docs/html/guide/developing/other-ide.jd b/docs/html/guide/developing/other-ide.jd
index ff13f43..8c61771a 100644
--- a/docs/html/guide/developing/other-ide.jd
+++ b/docs/html/guide/developing/other-ide.jd
@@ -555,11 +555,11 @@
 
 <ul>
 <li>If you are developing multiple related applications that use some of the
-same components, you move the redundant components out of their respective
+same components, you could move the redundant components out of their respective
 application projects and create a single, reuseable set of the same components
 in a library project. </li>
 <li>If you are creating an application that exists in both free and paid
-versions. You move the part of the application that is common to both versions
+versions, you could move the part of the application that is common to both versions
 into a library project. The two dependent projects, with their different package
 names, will reference the library project and provide only the difference
 between the two application versions.</li>
diff --git a/docs/html/guide/developing/tools/index.jd b/docs/html/guide/developing/tools/index.jd
index 0e10377..899c0dc 100644
--- a/docs/html/guide/developing/tools/index.jd
+++ b/docs/html/guide/developing/tools/index.jd
@@ -90,6 +90,11 @@
       level events.  You can use the Monkey to stress-test applications that you are developing,
       in a random yet repeatable manner.</dd>
 
+  <dt><a href="monkeyrunner_concepts.html">monkeyrunner</a></dt>
+  <dd>
+    The monkeyrunner tool provides an API for writing Python programs that control an Android device
+    or emulator from outside of Android code.
+  </dd>
   <dt><a  href="othertools.html#android">android</a></dt>
             <dd>A script that lets you manage AVDs and generate <a
                         href="http://ant.apache.org/" title="Ant">Ant</a> build files that
diff --git a/docs/html/guide/topics/manifest/uses-feature-element.jd b/docs/html/guide/topics/manifest/uses-feature-element.jd
index 4066daa..45f4a66 100644
--- a/docs/html/guide/topics/manifest/uses-feature-element.jd
+++ b/docs/html/guide/topics/manifest/uses-feature-element.jd
@@ -5,9 +5,9 @@
 
 <dt>syntax:</dt>
 <dd>
-<pre class="stx">&lt;uses-feature android:<a href="#glEsVersion">glEsVersion</a>="<em>integer</em>"
-              android:<a href="#name">name</a>="<em>string</em>"
-              android:<a href="#required">required</a>=["true" | "false"] /&gt;</pre>
+<pre class="stx">&lt;uses-feature android:<a href="#name">name</a>="<em>string</em>"
+              android:<a href="#required">required</a>=["true" | "false"]
+              android:<a href="#glEsVersion">glEsVersion</a>="<em>integer</em>" /&gt;</pre>
 </dd>
 
 <dt>contained in:</dt>
@@ -18,8 +18,8 @@
   <img id="rule" src="{@docRoot}assets/images/grad-rule-qv.png"> 
   <div id="qv-sub-rule"> 
     <img src="{@docRoot}assets/images/icon_market.jpg" style="float:left;margin:0;padding:0;"> 
-    <p style="color:#669999;">Android Market and &lt;uses-feature&gt; elements</p> 
-    <p>Android Market filters the applications that are visible to users, so
+    <p style="color:#669999;">Android Market and <code style="color:#669999;">&lt;uses-feature&gt;</code> elements</p>
+    <p style="margin-top:1em;">Android Market filters the applications that are visible to users, so
 that users can see and download only those applications that are compatible with their
 devices. One of the ways Market filters applications is by feature compatibility.</p>
 
@@ -27,70 +27,82 @@
 <code>&lt;uses-feature&gt;</code> elements in each application's manifest, to
 establish the app's feature needs. Market then shows or hides the application to
 each user, based on a comparison with the features available on the user's
-device. For more information, see <a
-href="{@docRoot}guide/appendix/market-filters.html">Market Filters</a>.</p>
+device. </p>
 
-<p style="margin-top:1em;">By specifying the features your application requires,
+<p style="margin-top:1em;">By specifying the features that your application requires,
 you enable Android Market to present your application only to users whose
 devices meet the application's feature requirements, rather than presenting it
 to all users. </p>
+
+<p style="margin-top:1em;" class="caution">For important information about how
+Android Market uses features as the basis for filtering, please read <a
+href="#market-feature-filtering">Android Market and Feature-Based Filtering</a>,
+below.</p>
 </div>
 </div>
 
 <dt>description:</dt>
-<dd>This element declares a specific feature used by the application. Android
-provides some features that may not be equally supported by all Android devices.
-In a manner similar to the <a
-href="uses-sdk-element.html">{@code &lt;uses-sdk>}</a> element, this element
-allows an application to specify which device-variable features it uses. For
-example, an application might specify that it requires a camera with auto-focus
-capabilities.</p>
+<dd>Declares a single hardware or software feature that is used by the
+application.
 
-<p>Declaring a {@code &lt;uses-feature>} element is informational only, meaning
+<p>The purpose of a <code>&lt;uses-feature&gt;</code> declaration is to inform
+any external entity of the set of hardware and software features on which your
+application depends. The element offers a <code>required</code> attribute that
+lets you specify whether your application requires and cannot function without
+the declared feature, or whether it prefers to have the feature but can function
+without it. Because feature support can vary across Android devices, the
+<code>&lt;uses-feature&gt;</code> element serves an important role in letting an
+application describe the device-variable features that it uses.</p>
+
+<p>The set of available features that your application declares corresponds to
+the set of feature constants made available by the Android {@link
+android.content.pm.PackageManager}, which are listed for
+convenience in the <a href="#features-reference">Features Reference</a> tables
+at the bottom of this document.
+
+<p>You must specify each feature in a separate <code>&lt;uses-feature&gt;</code>
+element, so if your application requires multiple features, it would declare
+multiple <code>&lt;uses-feature&gt;</code> elements. For example, an application
+that requires both Bluetooth and camera features in the device would declare
+these two elements:</p>
+
+<pre>
+&lt;uses-feature android:name="android.hardware.bluetooth" />
+&lt;uses-feature android:name="android.hardware.camera" />
+</pre>
+
+<p>In general, you should always make sure to declare
+<code>&lt;uses-feature&gt;</code> elements for all of the features that your
+application requires.</p>
+
+<p>Declared <code>&lt;uses-feature></code> elements are informational only, meaning
 that the Android system itself does not check for matching feature support on
-the device before installing an application. However, note that other services
+the device before installing an application. However, other services
 (such as Android Market) or applications may check your application's 
-{@code &lt;uses-feature>} declarations as part of handling or interacting 
+<code>&lt;uses-feature></code> declarations as part of handling or interacting
 with your application. For this reason, it's very important that you declare all of
 the features (from the list below) that your application uses. </p>
 
 <p>For some features, there may exist a specfic attribute that allows you to define
 a version of the feature, such as the version of Open GL used (declared with
-<a href="#glEsVersion">{@code glEsVersion}</a>). Other features that either do or do not
+<a href="#glEsVersion"><code>glEsVersion</code></a>). Other features that either do or do not
 exist for a device, such as a camera, are declared using the
-<a href="#name">{@code name}</a> attribute.</p>
+<a href="#name"><code>name</code></a> attribute.</p>
 
-<p>Any software or hardware features that may vary among Android-powered devices
-will be listed on this page among the attributes below. If you see any features
-here that you use in your application, you should include a
-{@code &lt;uses-feature>} element for each one. For example, if your
-application uses the device camera, then you should include the following in
-your {@code AndroidManifest.xml}:</p>
 
-<pre>
-&lt;uses-feature android:name="android.hardware.camera" />
-</pre>
+<p>Although the <code>&lt;uses-feature></code> element is only activated for
+devices running API Level 4 or higher, it is recommended to include these
+elements for all applications, even if the <a href="uses-sdk-element.html#min"><code>minSdkVersion</code></a>
+is "3" or lower. Devices running older versions of the platform will simply
+ignore the element.</p>
 
-<p>If you declare {@code android.hardware.camera} this way, then your application is considered
-compatible with all devices that include a camera. If your application also uses auto-focus
-features, then you also need to include a
-{@code &lt;uses-feature>} element that declares the {@code android.hardware.camera.autofocus}
-feature. Also note that you must still request the {@link android.Manifest.permission#CAMERA
-CAMERA} permission. Requesting the permission grants your application access to the
-appropriate hardware and software, while declaring the features used by
-your application ensures proper device compatibility.</p>
-
-<p>Although the {@code &lt;uses-feature>} element is only activated for devices running 
-API Level 4 or higher, it is safe to include this for applications that declare 
-a <a href="uses-sdk-element.html#min">{@code minSdkVersion}</a> 
-of "3" or lower. Devices running older versions of the platform 
-will simply ignore this element, but newer devices will recognize it and enforce 
-installation restrictions based on whether the device supports the feature.</p>
-
-<p class="note"><strong>Note:</strong>
-For each feature required by your application, you must include a new {@code
-&lt;uses-feature>} element. Multiple features cannot be declared in one 
-instance of this element.</p>
+<p class="note"><strong>Note:</strong> When declaring a feature, remember
+that you must also request permissions as appropriate. For example, you must
+still request the {@link android.Manifest.permission#CAMERA}
+permission before your application can access the camera API. Requesting the
+permission grants your application access to the appropriate hardware and
+software, while declaring the features used by your application ensures proper
+device compatibility.</p>
 
 </dd> 
 
@@ -99,7 +111,35 @@
 
 <dd>
 <dl class="attr">
-  <dt><a name="glEsVersion"></a>{@code android:glEsVersion}</dt>
+
+  <dt><a name="name"></a><code>android:name</code></dt>
+  <dd>Specifies a single hardware or software feature used by the application,
+as a descriptor string. Valid descriptor values are listed in the <a
+href="#hw-features">Hardware features</a> and <a href="#sw-features">Software
+features</a> tables, below. </dd>
+
+  <dt><a name="required"></a><code>android:required</code></dt>  <!-- added in api level 5 -->
+  <dd>Boolean value that indicates whether the application requires
+  the feature specified in <code>android:name</code>.
+
+<ul>
+<li>When you declare <code>"android:required="true"</code> for a feature,
+you are specifying that the application <em>cannot function, or is not
+designed to function</em>, when the specified feature is not present on the
+device. </li>
+
+<li>When you declare <code>"android:required="false"</code> for a feature, it
+means that the application <em>prefers to use the feature</em> if present on
+the device, but that it <em>is designed to function without the specified
+feature</em>, if necessary. </li>
+
+</ul>
+
+<p>The default value for <code>android:required</code> if not declared is
+<code>"true"</code>.</p>
+  </dd>
+
+  <dt><a name="glEsVersion"></a><code>android:glEsVersion</code></dt>
   <dd>The OpenGL ES version required by the application. The higher 16 bits
 represent the major number and the lower 16 bits represent the minor number. For
 example, to specify OpenGL ES version 2.0, you would set the value as
@@ -125,110 +165,6 @@
 can check at run-time whether a higher level of OpenGL ES is available.)</p>
   </dd>
 
-  <dt><a name="name"></a>{@code android:name}</dt>
-  <dd>The name of a feature required by the application. 
-  The value must be one of the following accepted strings:
-
-  <table>
-    <tr> 
-       <th>Feature</th>
-       <th>Attribute Value</th> 
-       <th>Description</th> 
-    </tr><tr>
-       <td rowspan="2">Camera</td>
-       <td>{@code android.hardware.camera}</td>
-       <td>The application requires a camera.</td> 
-    </tr><tr>
-       <td colspan="2">
-         <strong>Note:</strong> Any application that requests the 
-         {@link android.Manifest.permission#CAMERA} permission but does <em>not</em>
-         declare any camera features with the {@code &lt;uses-feature>} element will be assumed
-         to use all camera features (auto-focus and flash). Thus, the application will not
-         be compatible with devices that do not support all camera features. Please use
-         {@code &lt;uses-feature>} to declare only the camera features that your
-         application does need. For instance, if you request the
-         {@link android.Manifest.permission#CAMERA} permission, but you do not need auto-focus or
-          flash, then declare only the {@code android.hardware.camera} feature&mdash;the other
-          camera features that you do not request will no longer be assumed as required.
-       </td>
-    </tr><tr>
-      <td>Camera auto-focus</td>
-      <td>{@code android.hardware.camera.autofocus}</td>
-      <td>The application requires a camera with auto-focus capability.
-       As a prerequisite, {@code android.hardware.camera} must also be declared
-       with a separate {@code &lt;uses-feature>} element.
-      </td>
-    </tr><tr>
-      <td>Camera flash</td>
-      <td>{@code android.hardware.camera.flash}</td>
-      <td>The application requires a camera with a flash.
-        As a prerequisite, both {@code android.hardware.camera} and {@code
-        android.hardware.camera.autofocus} must also be declared
-        with separate {@code &lt;uses-feature>} elements.
-      </td>
-    </tr><tr>
-      <td>Light sensor</td>
-      <td>{@code android.hardware.sensor.light}</td>
-      <td>The application requires a device with a light sensor.
-      </td>
-    </tr><tr>
-      <td>Live Wallpaper</td>
-      <td>{@code android.software.live_wallpaper}</td>
-      <td>The application uses or provides Live Wallpapers and should be installed only on devices that support Live Wallpapers.
-      </td>
-    </tr><tr>
-      <td>Proximity sensor</td>
-      <td>{@code android.hardware.sensor.proximity}</td>
-      <td>The application requires a device with a proximity sensor.
-      </td>
-    </tr><tr>
-      <td>Multitouch screen</td>
-      <td>{@code android.hardware.touchscreen.multitouch}</td>
-      <td>The application requires a device that supports multitouch.
-      </td>
-    </tr><tr>
-      <td>Telephony</td>
-      <td>{@code android.hardware.telephony}</td>
-      <td>The application requires a device that includes a telephony radio with data
-         communication services.
-      </td>
-    </tr><tr>
-      <td>CDMA telephony</td>
-      <td>{@code android.hardware.telephony.cdma}</td>
-      <td>The application requires a device that includes a CDMA telephony radio. As a
-        prerequisite, {@code android.hardware.telephony} must also be declared
-        with a separate {@code &lt;uses-feature>} element.
-      </td>
-    </tr><tr>
-      <td>GSM telephony</td>
-      <td>{@code android.hardware.telephony.gsm}</td>
-      <td>The application requires a device that includes a GSM telephony radio. As a
-        prerequisite, {@code android.hardware.telephony} must also be declared
-        with a separate {@code &lt;uses-feature>} element.
-      </td>
-    </tr>
-  </table>
-  </dd>
-
-  <dt><a name="required"></a>{@code android:required}</dt>  <!-- added in api level 5 -->
-  <dd>Indicates whether the feature is required by the application. This is
-    {@code true} by default. <strong>You should not use this attribute for most cases.</strong>
-    </p>
-
-    <p>The only situation in which you should set this attribute {@code false} is when your
-    application requests the {@link android.Manifest.permission#CAMERA} permission, but will degrade
-    gracefully and perform without failure if the device does not have a camera. In this situation,
-    you must declare the {@code android.hardware.camera} feature and set the {@code required}
-    attribute {@code false}. This is necessary because the {@link
-    android.Manifest.permission#CAMERA} permission will automatically turn on the requirement for
-    all camera features. So if your application uses this permission but is still compatible with
-    devices without a camera, then you must set the {@code required} attribute {@code false} for
-    {@code android.hardware.camera} or else it will not install on devices without a camera. Note
-    that, while the permission will enable the requirement for <em>all</em> camera features, you
-    only need to off the requirement for the basic camera feature.</p>
-
-  </dd>
-
 </dl>
 </dd>
 
@@ -239,8 +175,680 @@
 <dt>see also:</dt>
 <dd>
   <ul>
+    <li>{@link android.content.pm.PackageManager}</li>
+    <li>{@link android.content.pm.FeatureInfo}</li>
     <li>{@link android.content.pm.ConfigurationInfo}</li>
+    <li><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><code>&lt;uses-permission&gt;</code></a></li>
+    <li><a href="{@docRoot}guide/appendix/market-filters.html">Android Market Filters</a></li>
   </ul>
 </dd>
 
 </dl>
+
+
+<h2 id="market-feature-filtering">Android Market and Feature-Based Filtering</h2>
+
+<p>Android Market filters the applications that are visible to users, so that
+users can see and download only those applications that are compatible with
+their devices. One of the ways Market filters applications is by feature
+compatibility.</p>
+
+<p>To determine an application's feature compatibility with a given user's
+device, the Android Market service compares:</p>
+
+<ul>
+<li>Features required by the application &mdash; an application declares features in
+<code>&lt;uses-feature&gt;</code> elements in its manifest <br/>with...</li>
+<li>Features available on the device, in hardware or software &mdash;
+a device reports the features it supports as read-only system properties.</li>
+</ul>
+
+<p>To ensure an accurate comparison of features, the Android Package Manager
+provides a shared set of feature constants that both applications and devices
+use to declare feature requirements and support. The available feature constants
+are listed in the <a href="#features-reference">Features Reference</a> tables at
+the bottom of this document, and in the class documentation for {@link
+android.content.pm.PackageManager}.</p>
+
+<p>When the user launches the Market application, the application queries the
+Package Manager for the list of features available on the device by calling
+{@link android.content.pm.PackageManager#getSystemAvailableFeatures()}. The
+Market application then passes the features list up to the Android Market
+service when establishing the session for the user.</p>
+
+<p>Each time you upload an application to the Android Market Publisher Site,
+Android Market scans the application's manifest file. It looks for
+<code>&lt;uses-feature&gt;</code> elements and evaluates them in combination
+with other elements, in some cases, such as <code>&lt;uses-sdk&gt;</code> and
+<code>&lt;uses-permission&gt;</code> elements. After establishing the
+application's set of required features, it stores that list internally as
+metadata associated with the application <code>.apk</code> and the application
+version. </p>
+
+<p>When a user searches or browses for applications using the Android Market
+application, the service compares the features needed by each application with
+the features available on the user's device. If all of an application's required
+features are present on the device, Android Market allows the user to see the
+application and potentially download it. If any required feature is not
+supported by the device, Android Market filters the application so that it is
+not visible to the user and not available for download. </p>
+
+<p>Because the features you declare in <code>&lt;uses-feature&gt;</code>
+elements directly affect how Android Market filters your application, it's
+important to understand how Android Market evaluates the application's manifest
+and establishes the set of required features. The sections below provide more
+information. </p>
+
+<h3 id="declared">Filtering based on explicitly declared features</h3>
+
+<p>An explicitly declared feature is one that your application declares in a
+<code>&lt;uses-feature&gt;</code> element. The feature declaration can include
+an <code>android:required=["true" | "false"]</code> attribute (if you are
+compiling against API level 5 or higher), which lets you specify whether the
+application absolutely requires the feature and cannot function properly without
+it (<code>"true"</code>), or whether the application prefers to use the feature
+if available, but is designed to run without it (<code>"false"</code>).</p>
+
+<p>Android Market handles explictly declared features in this way: </p>
+
+<ul>
+<li>If a feature is explicitly declared as being required, Android Market adds
+the feature to the list of required features for the application. It then
+filters the application from users on devices that do not provide that feature.
+For example:
+<pre>&lt;uses-feature android:name="android.hardware.camera" android:required="true" /&gt;</pre></li>
+<li>If a feature is explicitly declared as <em>not</em> being required, Android
+Market <em>does not</em> add the feature to the list of required features. For
+that reason, an explicity declared non-required feature is never considered when
+filtering the application. Even if the device does not provide the declared
+feature, Android Market will still consider the application compatible with the
+device and will show it to the user, unless other filtering rules apply. For
+example:
+<pre>&lt;uses-feature android:name="android.hardware.camera" android:required="false" /&gt;</pre></li>
+<li>If a feature is explicitly declared, but without an
+<code>android:required</code> attribute, Android Market assumes that the feature
+is required and sets up filtering on it. </li>
+</ul>
+
+<p>In general, if your application is designed to run on Android 1.6 and earlier
+versions, the <code>android:required</code> attribute is not available in the
+API and Android Market assumes that any and all
+<code>&lt;uses-feature&gt;</code> declarations are required. </p>
+
+<p class="note"><strong>Note:</strong> By declaring a feature explicitly and
+including an <code>android:required="false"</code> attribute, you can
+effectively disable all filtering on Android Market for the specified feature.
+</p>
+
+
+<h3 id="implicit">Filtering based on implicit features</h3>
+
+<p>An <em>implicit</em> feature is one that an application requires in order to
+function properly, but which is <em>not</em> declared in a
+<code>&lt;uses-feature&gt;</code> element in the manifest file. Strictly
+speaking, every application should <em>always</em> declare all features that it
+uses or requires, so the absence of a declaration for a feature used by an
+application should be considered an error. However, as a safeguard for users and
+developers, Android Market looks for implicit features in each application and
+sets up filters for those features, just as it would do for an explicitly
+declared feature. </p>
+
+<p>An application might require a feature but not declare it because: </p>
+
+<ul>
+<li>The application was compiled against an older version of the Android library
+(Android 1.5 or earlier) and the <code>&lt;uses-feature&gt;</code> element was
+not available.</li>
+<li>The developer incorrectly assumed that the feature would be present on all
+devices and a declaration was unnecessary.</li>
+<li>The developer omitted the feature declaration accidentally.</li>
+<li>The developer declared the feature explicitly, but the declaration was not
+valid. For example, a spelling error in the <code>&lt;uses-feature&gt;</code>
+element name or an unrecognized string value for the
+<code>android:name</code> attribute would invalidate the feature declaration.
+</li>
+</ul>
+
+<p>To account for the cases above, Android Market attempts to discover an
+application's implied feature requirements by examining <em>other elements</em>
+declared in the manifest file, specifically,
+<code>&lt;uses-permission&gt;</code> elements.</p>
+
+<p>If an application requests hardware-related permissions, Android Market
+<em>assumes that the application uses the underlying hardware features and
+therefore requires those features</em>, even though there might be no
+corresponding to <code>&lt;uses-feature&gt;</code> declarations. For such
+permissions, Android Market adds the underlying hardware features to the
+metadata that it stores for the application and sets up filters for them.</p>
+
+<p>For example, if an application requests the <code>CAMERA</code> permission
+but does not declare a <code>&lt;uses-feature&gt;</code> element for
+<code>android.hardware.camera</code>, Android Market considers that the
+application requires a camera and should not be shown to users whose devices do
+not offer a camera.</p>
+
+<p>If you don't want Android Market to filter based on a specific implied
+feature, you can disable that behavior. To do so, declare the feature explicitly
+in a <code>&lt;uses-feature&gt;</code> element and include an 
+<code>android:required="false"</code> attribute. For example, to disable
+filtering derived from the <code>CAMERA</code> permission, you would declare
+the feature as shown below.</p>
+
+<pre>&lt;uses-feature android:name="android.hardware.camera" android:required="false" /&gt;</pre>
+
+<p class="caution">It's important to understand that the permissions that you
+request in <code>&lt;uses-permission&gt;</code> elements can directly affect how
+Android Market filters your application. The reference section <a
+href="permissions-features">Permissions that Imply Feature Requirements</a>,
+below, lists the full set of permissions that imply feature requirements and
+therefore trigger filtering.</p>
+
+<h3 id="bt-permission-handling">Special handling for Bluetooth feature</h3>
+
+<p>Android Market applies slightly different rules than described above, when
+determining filtering for Bluetooth.</p>
+
+<p>If an application declares a Bluetooth permission in a
+<code>&lt;uses-permission&gt;</code> element, but does not explicitly declare
+the Bluetooth feature in a <code>&lt;uses-feature&gt;</code> element, Android
+Market checks the version(s) of the Android platform on which the application is
+designed to run, as specified in the <code>&lt;uses-sdk&gt;</code> element. </p>
+
+<p>As shown in the table below, Android Market enables filtering for the
+Bluetooth feature only if the application declares its lowest or targeted
+platform as Android 2.0 (API level 5) or higher. However, note that Android
+market applies the normal rules for filtering when the application explicitly
+declares the Bluetooth feature in a <code>&lt;uses-feature&gt;</code> element.
+</p>
+
+<p class="caption"><strong>Table 1.</strong> How Android Market determines the
+Bluetooth feature requirement for an application that requests a Bluetooth
+permission but does not declare the Bluetooth feature in a
+<code>&lt;uses-feature&gt;</code> element.</p>
+
+<table style="margin-top:1em;">
+<tr>
+<th><nobr>If <code>minSdkVersion</code> is ...</nobr></th>
+<th><nobr>or <code>targetSdkVersion</code> is</nobr></th>
+<th>Result</th>
+</tr>
+<tr>
+<td><nobr>&lt;=4 (or uses-sdk is not declared)</nobr></td>
+<td>&lt;=4</td>
+<td>Android Market <em>will not</em> filter the application from any devices
+based on their reported support for the <code>android.hardware.bluetooth</code>
+feature.</td>
+</tr>
+<tr>
+<td>&lt;=4</td>
+<td>&gt;=5</td>
+<td rowspan="2">Android Market filters the application from any devices that
+do not support the <code>android.hardware.bluetooth</code> feature (including
+older releases).</td>
+</tr>
+<tr>
+<td>&gt;=5</td>
+<td>&gt;=5</td>
+</tr>
+</table>
+
+<p>The examples below illustrate the different filtering effects, based on how
+Android Market handles the Bluetooth feature. </p>
+
+<dl>
+<dt>In first example, an application that is designed to run on older API levels
+declares a Bluetooth permission, but does not declare the Bluetooth feature in a
+<code>&lt;uses-feature&gt;</code> element.</dt>
+<dd><em>Result:</em> Android Market does not filter the application from any device.</dd>
+</dl>
+
+<pre>&lt;manifest ...>
+...
+    &lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    &lt;uses-sdk android:minSdkVersion="3" />
+...
+&lt;/manifest></pre>
+
+<dl>
+<dt>In the second example, below, the same application also declares a target
+API level of "5". </dt>
+<dd><em>Result:</em> Android Market now assumes that the feature is required and
+will filter the application from all devices that do not report Bluetooth support,
+including devices running older versions of the platform. </dd>
+</dl>
+
+<pre>&lt;manifest ...>
+...
+    &lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    &lt;uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />
+...
+&lt;/manifest></pre>
+
+<dl>
+<dt>Here the same application now specifically declares the Bluetooth feature.</dt>
+<dd><em>Result:</em> Identical to the previous example (filtering is applied).</dd>
+</dl>
+
+<pre>&lt;manifest ...>
+...
+    &lt;uses-feature android:name="android.hardware.bluetooth" />
+    &lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    &lt;uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />
+...
+&lt;/manifest></pre>
+
+<dl>
+<dt>Finally, in the case below, the same application adds an
+<code>android:required="false"</code> attribute.</dt>
+<dd><em>Result:</em> Android Market disables filtering based on Bluetooth
+feature support, for all devices.</dd>
+</dl>
+
+<pre>&lt;manifest ...>
+...
+    &lt;uses-feature android:name="android.hardware.bluetooth" android:required="false" />
+    &lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    &lt;uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />
+...
+&lt;/manifest></pre>
+
+
+
+<h3>Testing the features required by your application</h3>
+
+<p>You can use the <code>aapt</code> tool, included in the Android SDK, to
+determine how Android Market will filter your application, based on its declared
+features and permissions. To do so, run  <code>aapt</code> with the <code>dump
+badging</code> command. This causes <code>aapt</code> to parse your
+application's manifest and apply the same rules as used by Android Market to
+determine the features that your application requires. </p>
+
+<p>To use the tool, follow these steps: </p>
+
+<ol>
+<li>First, build and export your application as an unsigned <code>.apk</code>.
+If you are developing in Eclipse with ADT, right-click the project and select
+<strong>Android Tools</strong> &gt; <strong>Export Unsigned Application
+Package</strong>. Select a destination filename and path and click
+<strong>OK</strong>. </li>
+<li>Next, locate the <code>aapt</code> tool, if it is not already in your PATH.
+If you are using SDK Tools r7 or earlier, you can find <code>aapt</code> in the
+<code>&lt;<em>SDK</em>&gt;/platforms/android-&lt;<em>platform</em>&gt;/tools/</code> directory.
+<p class="note"><strong>Note:</strong> You must use the version of
+<code>aapt</code> that is provided for the latest platform release available. If
+you do not have the latest platform release, download it using the <a
+href="{@docRoot}sdk/adding-components.html">Android SDK and AVD Manager</a>.
+</p></li>
+<li>Run <code>aapt</code> using this syntax: </li>
+</ol>
+
+<pre>$ aapt dump badging &lt;<em>path_to_exported_.apk</em>&gt;</pre>
+
+<p>Here's an example of the command output for the second Bluetooth example, above: </p>
+
+<pre>$ ./aapt dump badging BTExample.apk
+package: name='com.example.android.btexample' versionCode='' versionName=''
+<strong>uses-permission:'android.permission.BLUETOOTH_ADMIN'</strong>
+<strong>uses-feature:'android.hardware.bluetooth'</strong>
+sdkVersion:'3'
+targetSdkVersion:'5'
+application: label='BT Example' icon='res/drawable/app_bt_ex.png'
+launchable activity name='com.example.android.btexample.MyActivity'label='' icon=''
+uses-feature:'android.hardware.touchscreen'
+main
+supports-screens: 'small' 'normal' 'large'
+locales: '--_--'
+densities: '160'
+</pre>
+
+
+<h2 id=features-reference>Features Reference</h2>
+
+<p>The tables below provide reference information about hardware and software
+features and the permissions that can imply them on Android Market. </p>
+
+<h3 id="hw-features">Hardware features</h3>
+
+<p>The table below describes the hardware feature descriptors supported by the
+most current platform release. To signal that your application uses or requires
+a hardware feature, declare each value in a <code>android:name</code> attribute
+in a separate <code>&lt;uses-feature&gt;</code> element. </p>
+
+  <table>
+    <tr>
+       <th>Feature Type</th>
+       <th>Feature Descriptor</th>
+       <th>Description</th>
+       <th>Comments</th>
+    </tr>
+    <tr>
+       <td>Bluetooth</td>
+       <td><code>android.hardware.bluetooth</td>
+       <td>The application uses Bluetooth radio features in the device.</td>
+<td>
+</td>
+    </tr>
+    <tr>
+       <td rowspan="3">Camera</td>
+       <td><code>android.hardware.camera</code></td>
+       <td>The application uses the device's camera. If the device supports
+           multiple cameras, the application uses the camera that facing
+           away from the screen.</td>
+       <td></td>
+    </tr>
+<tr>
+  <td><code>android.hardware.camera.autofocus</code></td>
+  <td>Subfeature. The application uses the device camera's autofocus capability.</td>
+  <td rowspan="2">If declared with the <code>"android:required="true"</code>
+attribute, these subfeatures implicitly declare the
+<code>android.hardware.camera</code> parent feature. </td>
+</tr>
+<tr>
+  <td><code>android.hardware.camera.flash</code></td>
+  <td>Subfeature. The application uses the device camera's flash.</td>
+</tr>
+
+<tr>
+  <td rowspan="3">Location</td>
+  <td><code>android.hardware.location</code></td>
+  <td>The application uses one or more features on the device for determining
+location, such as GPS location, network location, or cell location.</td>
+  <td></td>
+</tr>
+<tr>
+  <td><code>android.hardware.location.network</code></td>
+  <td>Subfeature. The application uses coarse location coordinates obtained from
+a network-based geolocation system supported on the device.</td>
+  <td rowspan="2">If declared with the <code>"android:required="true"</code>
+attribute, these subfeatures implicitly declare the
+<code>android.hardware.location</code> parent feature. </td>
+</tr>
+<tr>
+  <td><code>android.hardware.location.gps</code></td>
+  <td>Subfeature. The application uses precise location coordinates obtained
+from a Global Positioning System receiver on the device. </td>
+</tr>
+
+<tr>
+  <td rowspan="4">Sensors</td>
+  <td><code>android.hardware.sensor.accelerometer</code></td>
+  <td>The application uses motion readings from an accelerometer on the
+device.</td>
+  <td></td>
+</tr>
+<tr>
+  <td><code>android.hardware.sensor.compass</code></td>
+  <td>The application uses directional readings from a magnetometer (compass) on
+the device.</td>
+  <td></td>
+</tr>
+<tr>
+  <td><code>android.hardware.sensor.light</code></td>
+  <td>The application uses the device's light sensor.</td>
+  <td></td>
+</tr>
+<tr>
+  <td><code>android.hardware.sensor.proximity</code></td>
+  <td>The application uses the device's proximity sensor.</td>
+  <td></td>
+</tr>
+<tr>
+  <td>Microphone</td>
+  <td><code>android.hardware.microphone</code></td>
+  <td>The application uses a microphone on the device.
+  </td>
+  <td></td>
+</tr>
+
+<tr>
+  <td rowspan="3">Telephony</td>
+  <td><code>android.hardware.telephony</code></td>
+  <td>The application uses telephony features on the device, such as telephony
+radio with data communication services.</td>
+  <td></td>
+</tr>
+<tr>
+  <td><code>android.hardware.telephony.cdma</code></td>
+  <td>Subfeature. The application uses CDMA telephony radio features on the
+device. </td>
+  <td rowspan="2">If declared with the <code>"android:required="true"</code>
+attribute, these subfeatures implicitly declare the
+<code>android.hardware.telephony</code> parent feature. </td>
+</tr>
+<tr>
+  <td><code>android.hardware.telephony.gsm</code></td>
+  <td>Subfeature. The application uses GSM telephony radio features on the
+device.</td>
+</tr>
+
+<tr>
+  <td rowspan="3">Touchscreen</td>
+  <td><code>android.hardware.touchscreen</code></td>
+  <td>The application uses touchscreen capabilities on the device.</td>
+  <td></td>
+</tr>
+<tr>
+  <td><code>android.hardware.touchscreen.multitouch</code></td>
+  <td>The application uses basic two-point multitouch capabilities on the device
+screen.</td>
+  <td>If declared with the <code>"android:required="true"</code> attribute, this
+subfeature implicitly declares the <code>android.hardware.touchscreen</code>
+parent feature. </td>
+</tr>
+<tr>
+  <td><code>android.hardware.touchscreen.multitouch.distinct</code></td>
+  <td>Subfeature. The application uses advanced multipoint multitouch
+capabilities on the device screen, such as for tracking two or more points fully
+independently.</td>
+  <td>If declared with the <code>"android:required="true"</code> attribute, this
+subfeature implicitly declares the
+<code>android.hardware.touchscreen.multitouch</code> parent feature. </td>
+</tr>
+
+<tr>
+  <td>Wifi</td>
+  <td><code>android.hardware.wifi</code></td>
+  <td>The application uses 802.11 networking (wifi) features on the device.</td>
+  <td></td>
+</tr>
+
+  </table>
+
+<h3 id="sw-features">Software features</h3>
+
+<p>The table below describes the software feature descriptors supported by the
+most current platform release. To signal that your application uses or requires
+a software feature, declare each value in a <code>android:name</code> attribute
+in a separate <code>&lt;uses-feature&gt;</code> element. </p>
+
+
+  <table>
+    <tr> 
+       <th>Feature</th>
+       <th>Attribute Value</th> 
+       <th>Description</th>
+    </tr>
+    <tr>
+      <td>Live Wallpaper</td>
+      <td><code>android.software.live_wallpaper</code></td>
+      <td>The application uses or provides Live Wallpapers.
+      </td>
+    </tr>
+  </table>
+
+
+<h3 id="permissions">Permissions that Imply Feature Requirements</h3>
+
+<p>Some feature constants listed in the tables above were made available to
+applications <em>after</em> the corresponding API; for example, the
+<code>android.hardware.bluetooth</code> feature was added in Android 2.2 (API
+level 8), but the bluetooth API that it refers to was added in Android 2.0 (API
+level 5). Because of this, some apps were able to use the API before they had
+the ability to declare that they require the API via the
+<code>&lt;uses-feature&gt;</code> system. </p>
+
+<p>To prevent those apps from being made available unintentionally,  Android
+Market assumes that certain hardware-related permissions indicate that the
+underlying hardware features are required by default. For instance, applications
+that use Bluetooth must request the <code>BLUETOOTH</code> permission in a
+<code>&lt;uses-permission&gt;</code> element &mdash; for legacy apps, Android
+Market assumes that the permission declaration means that the underlying
+<code>android.hardware.bluetooth</code> feature is required by the application
+and sets up filtering based on that feature. </p>
+
+<p>The table below lists permissions that imply feature requirements
+equivalent to those declared in <code>&lt;uses-feature&gt;</code> elements. Note
+that <code>&lt;uses-feature&gt;</code> declarations, including any declared
+<code>android:required</code> attribute, always take precedence over features
+implied by the permissions below. </p>
+
+<p>For any of the permissions below, you can disable filtering based on the
+implied feature by explicitly declaring the implied feature explicitly, in a
+<code>&lt;uses-feature&gt;</code> element, with an
+<code>android:required="false"</code> attribute. For example, to disable any
+filtering based on the <code>CAMERA</code> permission, you would add this
+<code>&lt;uses-feature&gt;</code> declaration to the manifest file:</p>
+
+<pre>&lt;uses-feature android:name="android.hardware.camera" android:required="false" /&gt;</pre>
+
+<table id="permissions-features" >
+  <tr> 
+    <th>Category</th>
+    <th>This Permission...</th>
+    <th>Implies This Feature Requirement</th>
+    <!-- <th>Comments</th> -->
+  </tr>
+
+
+<tr>
+  <td rowspan="2">Bluetooth</td>
+  <td><code>BLUETOOTH</code></td>
+  <td><code>android.hardware.bluetooth</code>
+<p>(See <a href="#bt-permission-handling">Special handling for Bluetooth feature</a> for details.)</p></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>BLUETOOTH_ADMIN</code></td>
+  <td><code>android.hardware.bluetooth</code></td>
+<!--  <td></td> -->
+</tr>
+
+<tr>
+  <td>Camera</td>
+  <td><code>CAMERA</code></td>
+  <td><code>android.hardware.camera</code> <em>and</em>
+<br><code>android.hardware.camera.autofocus</code></td>
+<!--  <td></td> -->
+</tr>
+
+<tr>
+  <td rowspan="5">Location</td>
+  <td><code>ACCESS_MOCK_LOCATION</code></td>
+  <td><code>android.hardware.location</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>ACCESS_LOCATION_EXTRA_COMMANDS</code></td>
+  <td><code>android.hardware.location</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>INSTALL_LOCATION_PROVIDER</code></td>
+  <td><code>android.hardware.location</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>ACCESS_COARSE_LOCATION</code></td>
+  <td><code>android.hardware.location.network</code> <em>and</em>
+<br><code>android.hardware.location</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>ACCESS_FINE_LOCATION</code></td>
+  <td><code>android.hardware.location.gps</code> <em>and</em>
+<br><code>android.hardware.location</code></td>
+<!--  <td></td> -->
+</tr>
+
+<tr>
+  <td>Microphone</td>
+  <td><code>RECORD_AUDIO</code></td>
+  <td><code>android.hardware.microphone</code></td>
+<!--  <td></td> -->
+</tr>
+
+<tr>
+  <td rowspan="11">Telephony</td>
+  <td><code>CALL_PHONE</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>CALL_PRIVILEGED</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+
+<tr>
+  <td><code>MODIFY_PHONE_STATE</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>PROCESS_OUTGOING_CALLS</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>READ_SMS</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>RECEIVE_SMS</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>RECEIVE_MMS</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>RECEIVE_WAP_PUSH</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>SEND_SMS</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>WRITE_APN_SETTINGS</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>WRITE_SMS</code></td>
+  <td><code>android.hardware.telephony</code></td>
+<!--  <td></td> -->
+</tr>
+
+<tr>
+  <td rowspan="3">Wifi</td>
+  <td><code>ACCESS_WIFI_STATE</code></td>
+  <td><code>android.hardware.wifi</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>CHANGE_WIFI_STATE</code></td>
+  <td><code>android.hardware.wifi</code></td>
+<!--  <td></td> -->
+</tr>
+<tr>
+  <td><code>CHANGE_WIFI_MULTICAST_STATE</code></td>
+  <td><code>android.hardware.wifi</code></td>
+<!--  <td></td> -->
+</tr>
+</table>
\ No newline at end of file
diff --git a/docs/html/guide/topics/manifest/uses-permission-element.jd b/docs/html/guide/topics/manifest/uses-permission-element.jd
index aec765c..085b9f0 100644
--- a/docs/html/guide/topics/manifest/uses-permission-element.jd
+++ b/docs/html/guide/topics/manifest/uses-permission-element.jd
@@ -2,6 +2,38 @@
 @jd:body
 
 <dl class="xml">
+
+ <div class="sidebox-wrapper"> 
+  <img id="rule" src="{@docRoot}assets/images/grad-rule-qv.png"> 
+  <div id="qv-sub-rule"> 
+    <img src="{@docRoot}assets/images/icon_market.jpg" style="float:left;margin:0;padding:0;"> 
+    <p style="color:#669999;"><code style="color:#669999;">&lt;uses-permission&gt;</code> and filtering on Android Market. </p>
+
+<p style="margin-top:1em;">In some cases, the permissions that you request
+through <code>&lt;uses-permission&gt;</code> can affect how
+your application is filtered by Android Market.</p>
+
+<p style="margin-top:1em;">If you request a hardware-related permission &mdash;
+<code>CAMERA</code>, for example &mdash; Android Market assumes that your
+application requires the underlying hardware feature and filters the application
+from devices that do not offer it.</p>
+
+<p style="margin-top:1em;">To control filtering, always explicitly declare
+hardware features in <code>&lt;uses-feature&gt;</code> elements, rather than
+relying on Android Market to "discover" the requirements in
+<code>&lt;uses-permission&gt;</code> elements. Then, if you want to disable
+filtering for a particular feature, you can add a
+<code>android:required="false"</code> attribute to the
+<code>&lt;uses-feature&gt;</code> declaration.</p>
+
+<p style="margin-top:1em;" class="caution">For a list of permissions that imply
+hardware features, see the documentation for the <a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions-features">
+<code>&lt;uses-feature&gt;</code></a> element.</p>
+</div>
+</div>
+
+
 <dt>syntax:</dt>
 <dd><pre class="stx">&lt;uses-permission android:<a href="#nm">name</a>="<i>string</i>" /&gt;</pre></dd>
 
@@ -10,7 +42,7 @@
 
 <dt>description:</dt>
 <dd>Requests a permission that the application must be granted in 
-order for it to operate correctly.  Permissions are granted when the 
+order for it to operate correctly.  Permissions are granted by the user when the 
 application is installed, not while it's running.
 
 <p>
@@ -38,6 +70,11 @@
 <dd>API Level 1</dd>
 
 <dt>see also:</dt>
-<dd><code><a href="{@docRoot}guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></code></dd>
+<dd>
+<ul>
+  <li><code><a href="{@docRoot}guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></code></li>
+  <li><code><a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></code></li>
+</ul>
+</dd>
 
 </dl>
diff --git a/drm/common/DrmEngineBase.cpp b/drm/common/DrmEngineBase.cpp
index 17cdf544..10c64ee 100644
--- a/drm/common/DrmEngineBase.cpp
+++ b/drm/common/DrmEngineBase.cpp
@@ -120,6 +120,11 @@
     return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
 }
 
+status_t DrmEngineBase::openDecryptSession(
+    int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
+    return onOpenDecryptSession(uniqueId, decryptHandle, uri);
+}
+
 status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
     return onCloseDecryptSession(uniqueId, decryptHandle);
 }
diff --git a/drm/common/DrmInfoStatus.cpp b/drm/common/DrmInfoStatus.cpp
index f3a1516..8ec7311 100644
--- a/drm/common/DrmInfoStatus.cpp
+++ b/drm/common/DrmInfoStatus.cpp
@@ -19,8 +19,9 @@
 using namespace android;
 
 DrmInfoStatus::DrmInfoStatus(
-    int _statusCode, const DrmBuffer* _drmBuffer, const String8& _mimeType) :
+    int _statusCode, int _infoType, const DrmBuffer* _drmBuffer, const String8& _mimeType) :
     statusCode(_statusCode),
+    infoType(_infoType),
     drmBuffer(_drmBuffer),
     mimeType(_mimeType) {
 
diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp
index e46451d..c3d12f0 100644
--- a/drm/common/IDrmManagerService.cpp
+++ b/drm/common/IDrmManagerService.cpp
@@ -53,27 +53,18 @@
     remote()->transact(REMOVE_UNIQUEID, data, &reply);
 }
 
-status_t BpDrmManagerService::loadPlugIns(int uniqueId) {
-    LOGV("load plugins");
+void BpDrmManagerService::addClient(int uniqueId) {
     Parcel data, reply;
-
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
     data.writeInt32(uniqueId);
-
-    remote()->transact(LOAD_PLUGINS, data, &reply);
-    return reply.readInt32();
+    remote()->transact(ADD_CLIENT, data, &reply);
 }
 
-status_t BpDrmManagerService::loadPlugIns(int uniqueId, const String8& plugInDirPath) {
-    LOGV("load plugins from path");
+void BpDrmManagerService::removeClient(int uniqueId) {
     Parcel data, reply;
-
     data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
     data.writeInt32(uniqueId);
-    data.writeString8(plugInDirPath);
-
-    remote()->transact(LOAD_PLUGINS_FROM_PATH, data, &reply);
-    return reply.readInt32();
+    remote()->transact(REMOVE_CLIENT, data, &reply);
 }
 
 status_t BpDrmManagerService::setDrmServiceListener(
@@ -88,17 +79,6 @@
     return reply.readInt32();
 }
 
-status_t BpDrmManagerService::unloadPlugIns(int uniqueId) {
-    LOGV("unload plugins");
-    Parcel data, reply;
-
-    data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
-    data.writeInt32(uniqueId);
-
-    remote()->transact(UNLOAD_PLUGINS, data, &reply);
-    return reply.readInt32();
-}
-
 status_t BpDrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
     LOGV("Install DRM Engine");
     Parcel data, reply;
@@ -191,6 +171,7 @@
     if (0 != reply.dataAvail()) {
         //Filling DRM Info Status
         const int statusCode = reply.readInt32();
+        const int infoType = reply.readInt32();
         const String8 mimeType = reply.readString8();
 
         DrmBuffer* drmBuffer = NULL;
@@ -203,7 +184,7 @@
             }
             drmBuffer = new DrmBuffer(data, bufferSize);
         }
-        drmInfoStatus = new DrmInfoStatus(statusCode, drmBuffer, mimeType);
+        drmInfoStatus = new DrmInfoStatus(statusCode, infoType, drmBuffer, mimeType);
     }
     return drmInfoStatus;
 }
@@ -538,8 +519,7 @@
     LOGV("Entering BpDrmManagerService::openDecryptSession");
     Parcel data, reply;
 
-    const String16 interfaceDescriptor = IDrmManagerService::getInterfaceDescriptor();
-    data.writeInterfaceToken(interfaceDescriptor);
+    data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
     data.writeInt32(uniqueId);
     data.writeFileDescriptor(fd);
     data.writeInt32(offset);
@@ -563,6 +543,34 @@
     return handle;
 }
 
+DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char* uri) {
+    LOGV("Entering BpDrmManagerService::openDecryptSession");
+    Parcel data, reply;
+
+    data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
+    data.writeInt32(uniqueId);
+    data.writeString8(String8(uri));
+
+    remote()->transact(OPEN_DECRYPT_SESSION_FROM_URI, data, &reply);
+
+    DecryptHandle* handle = NULL;
+    if (0 != reply.dataAvail()) {
+        handle = new DecryptHandle();
+        handle->decryptId = reply.readInt32();
+        handle->mimeType = reply.readString8();
+        handle->decryptApiType = reply.readInt32();
+        handle->status = reply.readInt32();
+        handle->decryptInfo = NULL;
+        if (0 != reply.dataAvail()) {
+            handle->decryptInfo = new DecryptInfo();
+            handle->decryptInfo->decryptBufferLength = reply.readInt32();
+        }
+    } else {
+        LOGE("no decryptHandle is generated in service side");
+    }
+    return handle;
+}
+
 status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
     LOGV("closeDecryptSession");
     Parcel data, reply;
@@ -744,25 +752,19 @@
         return DRM_NO_ERROR;
     }
 
-    case LOAD_PLUGINS:
+    case ADD_CLIENT:
     {
-        LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS");
+        LOGV("BnDrmManagerService::onTransact :ADD_CLIENT");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
-
-        status_t status = loadPlugIns(data.readInt32());
-
-        reply->writeInt32(status);
+        addClient(data.readInt32());
         return DRM_NO_ERROR;
     }
 
-    case LOAD_PLUGINS_FROM_PATH:
+    case REMOVE_CLIENT:
     {
-        LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS_FROM_PATH");
+        LOGV("BnDrmManagerService::onTransact :REMOVE_CLIENT");
         CHECK_INTERFACE(IDrmManagerService, data, reply);
-
-        status_t status = loadPlugIns(data.readInt32(), data.readString8());
-
-        reply->writeInt32(status);
+        removeClient(data.readInt32());
         return DRM_NO_ERROR;
     }
 
@@ -781,18 +783,6 @@
         return DRM_NO_ERROR;
     }
 
-    case UNLOAD_PLUGINS:
-    {
-        LOGV("BnDrmManagerService::onTransact :UNLOAD_PLUGINS");
-        CHECK_INTERFACE(IDrmManagerService, data, reply);
-
-        const int uniqueId = data.readInt32();
-        status_t status = unloadPlugIns(uniqueId);
-
-        reply->writeInt32(status);
-        return DRM_NO_ERROR;
-    }
-
     case INSTALL_DRM_ENGINE:
     {
         LOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE");
@@ -879,6 +869,7 @@
         if (NULL != drmInfoStatus) {
             //Filling DRM Info Status contents
             reply->writeInt32(drmInfoStatus->statusCode);
+            reply->writeInt32(drmInfoStatus->infoType);
             reply->writeString8(drmInfoStatus->mimeType);
 
             if (NULL != drmInfoStatus->drmBuffer) {
@@ -1235,6 +1226,32 @@
         return DRM_NO_ERROR;
     }
 
+    case OPEN_DECRYPT_SESSION_FROM_URI:
+    {
+        LOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION_FROM_URI");
+        CHECK_INTERFACE(IDrmManagerService, data, reply);
+
+        const int uniqueId = data.readInt32();
+        const String8 uri = data.readString8();
+
+        DecryptHandle* handle = openDecryptSession(uniqueId, uri.string());
+
+        if (NULL != handle) {
+            reply->writeInt32(handle->decryptId);
+            reply->writeString8(handle->mimeType);
+            reply->writeInt32(handle->decryptApiType);
+            reply->writeInt32(handle->status);
+            if (NULL != handle->decryptInfo) {
+                reply->writeInt32(handle->decryptInfo->decryptBufferLength);
+                delete handle->decryptInfo; handle->decryptInfo = NULL;
+            }
+        } else {
+            LOGE("NULL decryptHandle is returned");
+        }
+        delete handle; handle = NULL;
+        return DRM_NO_ERROR;
+    }
+
     case CLOSE_DECRYPT_SESSION:
     {
         LOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION");
diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp
index 645d2c6..35e62f3 100644
--- a/drm/drmserver/DrmManager.cpp
+++ b/drm/drmserver/DrmManager.cpp
@@ -85,22 +85,31 @@
     }
 }
 
-status_t DrmManager::loadPlugIns(int uniqueId) {
+status_t DrmManager::loadPlugIns() {
     String8 pluginDirPath("/system/lib/drm/plugins/native");
-    return loadPlugIns(uniqueId, pluginDirPath);
+    return loadPlugIns(pluginDirPath);
 }
 
-status_t DrmManager::loadPlugIns(int uniqueId, const String8& plugInDirPath) {
+status_t DrmManager::loadPlugIns(const String8& plugInDirPath) {
     if (mSupportInfoToPlugInIdMap.isEmpty()) {
         mPlugInManager.loadPlugIns(plugInDirPath);
-
-        initializePlugIns(uniqueId);
-
-        populate(uniqueId);
-    } else {
-        initializePlugIns(uniqueId);
+        Vector<String8> plugInPathList = mPlugInManager.getPlugInIdList();
+        for (unsigned int i = 0; i < plugInPathList.size(); ++i) {
+            String8 plugInPath = plugInPathList[i];
+            DrmSupportInfo* info = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(0);
+            if (NULL != info) {
+                mSupportInfoToPlugInIdMap.add(*info, plugInPath);
+            }
+        }
     }
+    return DRM_NO_ERROR;
+}
 
+status_t DrmManager::unloadPlugIns() {
+    mConvertSessionMap.clear();
+    mDecryptSessionMap.clear();
+    mPlugInManager.unloadPlugIns();
+    mSupportInfoToPlugInIdMap.clear();
     return DRM_NO_ERROR;
 }
 
@@ -111,21 +120,23 @@
     return DRM_NO_ERROR;
 }
 
-status_t DrmManager::unloadPlugIns(int uniqueId) {
-    Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
+void DrmManager::addClient(int uniqueId) {
+    if (!mSupportInfoToPlugInIdMap.isEmpty()) {
+        Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
+        for (unsigned int index = 0; index < plugInIdList.size(); index++) {
+            IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
+            rDrmEngine.initialize(uniqueId);
+            rDrmEngine.setOnInfoListener(uniqueId, this);
+        }
+    }
+}
 
+void DrmManager::removeClient(int uniqueId) {
+    Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
     for (unsigned int index = 0; index < plugInIdList.size(); index++) {
         IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
         rDrmEngine.terminate(uniqueId);
     }
-
-    if (0 >= mUniqueIdVector.size()) {
-        mConvertSessionMap.clear();
-        mDecryptSessionMap.clear();
-        mSupportInfoToPlugInIdMap.clear();
-        mPlugInManager.unloadPlugIns();
-    }
-    return DRM_NO_ERROR;
 }
 
 DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, const int action) {
@@ -144,7 +155,7 @@
     rDrmEngine.initialize(uniqueId);
     rDrmEngine.setOnInfoListener(uniqueId, this);
 
-    DrmSupportInfo* info = rDrmEngine.getSupportInfo(uniqueId);
+    DrmSupportInfo* info = rDrmEngine.getSupportInfo(0);
     mSupportInfoToPlugInIdMap.add(*info, absolutePath);
 
     return DRM_NO_ERROR;
@@ -154,7 +165,7 @@
     const String8 plugInId = getSupportedPlugInId(mimeType);
     bool result = (EMPTY_STRING != plugInId) ? true : false;
 
-    if (NULL != path) {
+    if (0 < path.length()) {
         if (result) {
             IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
             result = rDrmEngine.canHandle(uniqueId, path);
@@ -340,7 +351,7 @@
         for (int i = 0; i < size; ++i) {
             String8 plugInPath = plugInPathList[i];
             DrmSupportInfo* drmSupportInfo
-                = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(uniqueId);
+                = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(0);
             if (NULL != drmSupportInfo) {
                 drmSupportInfoList.add(*drmSupportInfo);
                 delete drmSupportInfo; drmSupportInfo = NULL;
@@ -360,12 +371,12 @@
 }
 
 DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset, int length) {
+    Mutex::Autolock _l(mDecryptLock);
     status_t result = DRM_ERROR_CANNOT_HANDLE;
     Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
 
     DecryptHandle* handle = new DecryptHandle();
     if (NULL != handle) {
-        Mutex::Autolock _l(mDecryptLock);
         handle->decryptId = mDecryptSessionId + 1;
 
         for (unsigned int index = 0; index < plugInIdList.size(); index++) {
@@ -380,15 +391,42 @@
             }
         }
     }
-
     if (DRM_NO_ERROR != result) {
         delete handle; handle = NULL;
     }
+    return handle;
+}
 
+DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
+    Mutex::Autolock _l(mDecryptLock);
+    status_t result = DRM_ERROR_CANNOT_HANDLE;
+    Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
+
+    DecryptHandle* handle = new DecryptHandle();
+    if (NULL != handle) {
+        handle->decryptId = mDecryptSessionId + 1;
+
+        for (unsigned int index = 0; index < plugInIdList.size(); index++) {
+            String8 plugInId = plugInIdList.itemAt(index);
+            IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
+            result = rDrmEngine.openDecryptSession(uniqueId, handle, uri);
+
+            if (DRM_NO_ERROR == result) {
+                ++mDecryptSessionId;
+                mDecryptSessionMap.add(mDecryptSessionId, &rDrmEngine);
+                break;
+            }
+        }
+    }
+    if (DRM_NO_ERROR != result) {
+        delete handle; handle = NULL;
+        LOGE("DrmManager::openDecryptSession: no capable plug-in found");
+    }
     return handle;
 }
 
 status_t DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+    Mutex::Autolock _l(mDecryptLock);
     status_t result = DRM_ERROR_UNKNOWN;
     if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
         IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
@@ -442,28 +480,6 @@
     return result;
 }
 
-void DrmManager::initializePlugIns(int uniqueId) {
-    Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
-
-    for (unsigned int index = 0; index < plugInIdList.size(); index++) {
-        IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
-        rDrmEngine.initialize(uniqueId);
-        rDrmEngine.setOnInfoListener(uniqueId, this);
-    }
-}
-
-void DrmManager::populate(int uniqueId) {
-    Vector<String8> plugInPathList = mPlugInManager.getPlugInIdList();
-
-    for (unsigned int i = 0; i < plugInPathList.size(); ++i) {
-        String8 plugInPath = plugInPathList[i];
-        DrmSupportInfo* info = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(uniqueId);
-        if (NULL != info) {
-            mSupportInfoToPlugInIdMap.add(*info, plugInPath);
-        }
-    }
-}
-
 String8 DrmManager::getSupportedPlugInId(
             int uniqueId, const String8& path, const String8& mimeType) {
     String8 plugInId("");
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp
index cf9bab1..8cf510d 100644
--- a/drm/drmserver/DrmManagerService.cpp
+++ b/drm/drmserver/DrmManagerService.cpp
@@ -27,21 +27,21 @@
 
 using namespace android;
 
-#define SUCCESS 0
-
 void DrmManagerService::instantiate() {
     LOGV("instantiate");
     defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService());
 }
 
-DrmManagerService::DrmManagerService() {
+DrmManagerService::DrmManagerService() :
+        mDrmManager(NULL) {
     LOGV("created");
-    mDrmManager = NULL;
     mDrmManager = new DrmManager();
+    mDrmManager->loadPlugIns();
 }
 
 DrmManagerService::~DrmManagerService() {
     LOGV("Destroyed");
+    mDrmManager->unloadPlugIns();
     delete mDrmManager; mDrmManager = NULL;
 }
 
@@ -53,14 +53,12 @@
     mDrmManager->removeUniqueId(uniqueId);
 }
 
-status_t DrmManagerService::loadPlugIns(int uniqueId) {
-    LOGV("Entering load plugins");
-    return mDrmManager->loadPlugIns(uniqueId);
+void DrmManagerService::addClient(int uniqueId) {
+    mDrmManager->addClient(uniqueId);
 }
 
-status_t DrmManagerService::loadPlugIns(int uniqueId, const String8& plugInDirPath) {
-    LOGV("Entering load plugins from path");
-    return mDrmManager->loadPlugIns(uniqueId, plugInDirPath);
+void DrmManagerService::removeClient(int uniqueId) {
+    mDrmManager->removeClient(uniqueId);
 }
 
 status_t DrmManagerService::setDrmServiceListener(
@@ -70,11 +68,6 @@
     return DRM_NO_ERROR;
 }
 
-status_t DrmManagerService::unloadPlugIns(int uniqueId) {
-    LOGV("Entering unload plugins");
-    return mDrmManager->unloadPlugIns(uniqueId);
-}
-
 status_t DrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
     LOGV("Entering installDrmEngine");
     return mDrmManager->installDrmEngine(uniqueId, drmEngineFile);
@@ -182,6 +175,12 @@
     return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
 }
 
+DecryptHandle* DrmManagerService::openDecryptSession(
+            int uniqueId, const char* uri) {
+    LOGV("Entering DrmManagerService::openDecryptSession with uri");
+    return mDrmManager->openDecryptSession(uniqueId, uri);
+}
+
 status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
     LOGV("Entering closeDecryptSession");
     return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
diff --git a/drm/java/android/drm/DrmErrorEvent.java b/drm/java/android/drm/DrmErrorEvent.java
index 8e71634..9294884 100644
--- a/drm/java/android/drm/DrmErrorEvent.java
+++ b/drm/java/android/drm/DrmErrorEvent.java
@@ -45,35 +45,19 @@
      */
     public static final int TYPE_NO_INTERNET_CONNECTION = 2005;
     /**
-     * TYPE_REGISTRATION_FAILED, when failed to register with the service.
+     * TYPE_PROCESS_DRM_INFO_FAILED, when failed to process DrmInfo.
      */
-    public static final int TYPE_REGISTRATION_FAILED = 2006;
-    /**
-     * TYPE_UNREGISTRATION_FAILED, when failed to unregister with the service.
-     */
-    public static final int TYPE_UNREGISTRATION_FAILED = 2007;
-    /**
-     * TYPE_RIGHTS_ACQUISITION_FAILED, when failed to acquire the rights information required.
-     */
-    public static final int TYPE_RIGHTS_ACQUISITION_FAILED = 2008;
-    /**
-     * TYPE_INITIALIZE_FAILED, when failed to load and initialize the available plugins.
-     */
-    public static final int TYPE_INITIALIZE_FAILED = 2009;
-    /**
-     * TYPE_FINALIZE_FAILED, when failed to unload and finalize the loaded plugins.
-     */
-    public static final int TYPE_FINALIZE_FAILED = 2010;
+    public static final int TYPE_PROCESS_DRM_INFO_FAILED = 2006;
     /**
      * TYPE_REMOVE_ALL_RIGHTS_FAILED, when failed to remove all the rights objects
      * associated with all DRM schemes.
      */
-    public static final int TYPE_REMOVE_ALL_RIGHTS_FAILED = 2011;
+    public static final int TYPE_REMOVE_ALL_RIGHTS_FAILED = 2007;
     /**
      * TYPE_DRM_INFO_ACQUISITION_FAILED, when failed to get the required information to
      * communicate with the service.
      */
-    public static final int TYPE_DRM_INFO_ACQUISITION_FAILED = 2012;
+    public static final int TYPE_DRM_INFO_ACQUISITION_FAILED = 2008;
 
     /**
      * constructor to create DrmErrorEvent object with given parameters
diff --git a/drm/java/android/drm/DrmEvent.java b/drm/java/android/drm/DrmEvent.java
index d6e0c3a..583337f 100644
--- a/drm/java/android/drm/DrmEvent.java
+++ b/drm/java/android/drm/DrmEvent.java
@@ -23,35 +23,19 @@
  */
 public class DrmEvent {
     /**
-     * Constant field signifies that unload and finalize the loaded plugins successfully
-     */
-    public static final int TYPE_FINALIZED = 1001;
-    /**
-     * Constant field signifies that register with the service successfully
-     */
-    public static final int TYPE_REGISTERED = 1002;
-    /**
-     * Constant field signifies that load and initialized the available plugins successfully
-     */
-    public static final int TYPE_INITIALIZED = 1003;
-    /**
-     * Constant field signifies that unregister with the service successfully
-     */
-    public static final int TYPE_UNREGISTERED = 1004;
-    /**
-     * Constant field signifies that rights information is acquired successfully
-     */
-    public static final int TYPE_RIGHTS_ACQUIRED = 1005;
-    /**
      * Constant field signifies that all the rights information associated with
      * all DRM schemes are removed successfully
      */
-    public static final int TYPE_ALL_RIGHTS_REMOVED = 1006;
+    public static final int TYPE_ALL_RIGHTS_REMOVED = 1001;
+    /**
+     * Constant field signifies that given information is processed successfully
+     */
+    public static final int TYPE_DRM_INFO_PROCESSED = 1002;
     /**
      * Constant field signifies that the required information to communicate with
      * the service is acquired sucessfully
      */
-    public static final int TYPE_DRM_INFO_ACQUIRED = 1007;
+    public static final int TYPE_DRM_INFO_ACQUIRED = 1003;
 
     public static final String DRM_INFO_STATUS_OBJECT = "drm_info_status_object";
     public static final String DRM_INFO_OBJECT = "drm_info_object";
diff --git a/drm/java/android/drm/DrmInfoStatus.java b/drm/java/android/drm/DrmInfoStatus.java
index 7e9ca3e..b37ea51 100644
--- a/drm/java/android/drm/DrmInfoStatus.java
+++ b/drm/java/android/drm/DrmInfoStatus.java
@@ -31,6 +31,7 @@
     public static final int STATUS_ERROR = 2;
 
     public final int statusCode;
+    public final int infoType;
     public final String mimeType;
     public final ProcessedData data;
 
@@ -38,11 +39,13 @@
      * constructor to create DrmInfoStatus object with given parameters
      *
      * @param _statusCode Status of the communication
+     * @param _infoType Type of the DRM information processed
      * @param _data The processed data
      * @param _mimeType MIME type
      */
-    public DrmInfoStatus(int _statusCode, ProcessedData _data, String _mimeType) {
+    public DrmInfoStatus(int _statusCode, int _infoType, ProcessedData _data, String _mimeType) {
         statusCode = _statusCode;
+        infoType = _infoType;
         data = _data;
         mimeType = _mimeType;
     }
diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java
index 147c530..5044d36 100644
--- a/drm/java/android/drm/DrmManagerClient.java
+++ b/drm/java/android/drm/DrmManagerClient.java
@@ -16,9 +16,11 @@
 
 package android.drm;
 
+import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.content.Context;
 import android.database.Cursor;
+import android.database.sqlite.SQLiteException;
 import android.net.Uri;
 import android.os.Handler;
 import android.os.HandlerThread;
@@ -99,14 +101,9 @@
         public void onError(DrmManagerClient client, DrmErrorEvent event);
     }
 
-    private static final int STATE_UNINITIALIZED = 0;
-    private static final int STATE_INITIALIZED = 1;
-
-    private static final int ACTION_INITIALIZE = 1000;
-    private static final int ACTION_FINALIZE = 1001;
-    private static final int ACTION_REMOVE_ALL_RIGHTS = 1002;
-    private static final int ACTION_ACQUIRE_DRM_INFO = 1003;
-    private static final int ACTION_PROCESS_DRM_INFO = 1004;
+    private static final int ACTION_REMOVE_ALL_RIGHTS = 1001;
+    private static final int ACTION_ACQUIRE_DRM_INFO = 1002;
+    private static final int ACTION_PROCESS_DRM_INFO = 1003;
 
     private int mUniqueId;
     private int mNativeContext;
@@ -116,7 +113,6 @@
     private OnInfoListener mOnInfoListener;
     private OnEventListener mOnEventListener;
     private OnErrorListener mOnErrorListener;
-    private int mCurrentState = STATE_UNINITIALIZED;
 
     private class EventHandler extends Handler {
 
@@ -130,16 +126,6 @@
             HashMap<String, Object> attributes = new HashMap<String, Object>();
 
             switch(msg.what) {
-            case ACTION_INITIALIZE: {
-                if (ERROR_NONE == _loadPlugIns(mUniqueId, msg.obj)) {
-                    mCurrentState = STATE_INITIALIZED;
-                    event = new DrmEvent(mUniqueId, DrmEvent.TYPE_INITIALIZED, null);
-                } else {
-                    error = new DrmErrorEvent(mUniqueId,
-                            DrmErrorEvent.TYPE_INITIALIZE_FAILED, null);
-                }
-                break;
-            }
             case ACTION_ACQUIRE_DRM_INFO: {
                 final DrmInfoRequest request = (DrmInfoRequest) msg.obj;
                 DrmInfo drmInfo = _acquireDrmInfo(mUniqueId, request);
@@ -157,10 +143,10 @@
                 DrmInfoStatus status = _processDrmInfo(mUniqueId, drmInfo);
                 if (null != status && DrmInfoStatus.STATUS_OK == status.statusCode) {
                     attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status);
-                    event = new DrmEvent(mUniqueId, getEventType(drmInfo.getInfoType()), null);
+                    event = new DrmEvent(mUniqueId, getEventType(status.infoType), null);
                 } else {
-                    error = new DrmErrorEvent(mUniqueId,
-                            getErrorType(drmInfo.getInfoType()), null);
+                    int infoType = (null != status) ? status.infoType : drmInfo.getInfoType();
+                    error = new DrmErrorEvent(mUniqueId, getErrorType(infoType), null);
                 }
                 break;
             }
@@ -173,16 +159,6 @@
                 }
                 break;
             }
-            case ACTION_FINALIZE: {
-                if (ERROR_NONE == _unloadPlugIns(mUniqueId)) {
-                    mCurrentState = STATE_UNINITIALIZED;
-                    event = new DrmEvent(mUniqueId, DrmEvent.TYPE_FINALIZED, null);
-                } else {
-                    error = new DrmErrorEvent(mUniqueId,
-                            DrmErrorEvent.TYPE_FINALIZE_FAILED, null);
-                }
-                break;
-            }
             default:
                 Log.e(TAG, "Unknown message type " + msg.what);
                 return;
@@ -283,6 +259,12 @@
 
         // save the unique id
         mUniqueId = hashCode();
+
+        _initialize(mUniqueId, new WeakReference<DrmManagerClient>(this));
+    }
+
+    protected void finalize() {
+        _finalize(mUniqueId);
     }
 
     /**
@@ -322,58 +304,11 @@
     }
 
     /**
-     * Initializes DrmFramework, which loads all available plug-ins
-     * in the default plug-in directory path
-     *
-     * @return
-     *     ERROR_NONE for success
-     *     ERROR_UNKNOWN for failure
-     */
-    public int loadPlugIns() {
-        int result = ERROR_UNKNOWN;
-        if (STATE_UNINITIALIZED == getState()) {
-            if (null != mEventHandler) {
-                Message msg = mEventHandler.obtainMessage(
-                        ACTION_INITIALIZE, new WeakReference<DrmManagerClient>(this));
-                result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
-            }
-        } else {
-            result = ERROR_NONE;
-        }
-        return result;
-    }
-
-    /**
-     * Finalize DrmFramework, which release resources associated with each plug-in
-     * and unload all plug-ins.
-     *
-     * @return
-     *     ERROR_NONE for success
-     *     ERROR_UNKNOWN for failure
-     */
-    public int unloadPlugIns() {
-        int result = ERROR_UNKNOWN;
-        if (STATE_INITIALIZED == getState()) {
-            if (null != mEventHandler) {
-                Message msg = mEventHandler.obtainMessage(ACTION_FINALIZE);
-                result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
-            }
-        } else {
-            result = ERROR_NONE;
-        }
-        return result;
-    }
-
-    /**
      * Retrieves informations about all the plug-ins registered with DrmFramework.
      *
      * @return Array of DrmEngine plug-in strings
      */
     public String[] getAvailableDrmEngines() {
-        if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
-        }
-
         DrmSupportInfo[] supportInfos = _getAllSupportInfo(mUniqueId);
         ArrayList<String> descriptions = new ArrayList<String>();
 
@@ -396,8 +331,6 @@
     public ContentValues getConstraints(String path, int action) {
         if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
             throw new IllegalArgumentException("Given usage or path is invalid/null");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         return _getConstraints(mUniqueId, path, action);
     }
@@ -411,6 +344,9 @@
      *         or null in case of failure
      */
     public ContentValues getConstraints(Uri uri, int action) {
+        if (null == uri || Uri.EMPTY == uri) {
+            throw new IllegalArgumentException("Uri should be non null");
+        }
         return getConstraints(convertUriToPath(uri), action);
     }
 
@@ -432,8 +368,6 @@
             DrmRights drmRights, String rightsPath, String contentPath) throws IOException {
         if (null == drmRights || !drmRights.isValid()) {
             throw new IllegalArgumentException("Given drmRights or contentPath is not valid");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         if (null != rightsPath && !rightsPath.equals("")) {
             DrmUtils.writeToFile(rightsPath, drmRights.getData());
@@ -451,8 +385,6 @@
         if (null == engineFilePath || engineFilePath.equals("")) {
             throw new IllegalArgumentException(
                 "Given engineFilePath: "+ engineFilePath + "is not valid");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         _installDrmEngine(mUniqueId, engineFilePath);
     }
@@ -464,14 +396,11 @@
      * @param mimeType Mimetype of the object to be handled
      * @return
      *        true - if the given mimeType or path can be handled
-     *        false - cannot be handled. false will be return in case
-     *        the state is uninitialized
+     *        false - cannot be handled.
      */
     public boolean canHandle(String path, String mimeType) {
         if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
             throw new IllegalArgumentException("Path or the mimetype should be non null");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         return _canHandle(mUniqueId, path, mimeType);
     }
@@ -483,8 +412,7 @@
      * @param mimeType Mimetype of the object to be handled
      * @return
      *        true - if the given mimeType or path can be handled
-     *        false - cannot be handled. false will be return in case
-     *        the state is uninitialized
+     *        false - cannot be handled.
      */
     public boolean canHandle(Uri uri, String mimeType) {
         if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
@@ -504,8 +432,6 @@
     public int processDrmInfo(DrmInfo drmInfo) {
         if (null == drmInfo || !drmInfo.isValid()) {
             throw new IllegalArgumentException("Given drmInfo is invalid/null");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         int result = ERROR_UNKNOWN;
         if (null != mEventHandler) {
@@ -526,8 +452,6 @@
     public int acquireDrmInfo(DrmInfoRequest drmInfoRequest) {
         if (null == drmInfoRequest || !drmInfoRequest.isValid()) {
             throw new IllegalArgumentException("Given drmInfoRequest is invalid/null");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         int result = ERROR_UNKNOWN;
         if (null != mEventHandler) {
@@ -550,8 +474,6 @@
     public int getDrmObjectType(String path, String mimeType) {
         if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
             throw new IllegalArgumentException("Path or the mimetype should be non null");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         return _getDrmObjectType(mUniqueId, path, mimeType);
     }
@@ -589,8 +511,6 @@
     public String getOriginalMimeType(String path) {
         if (null == path || path.equals("")) {
             throw new IllegalArgumentException("Given path should be non null");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         return _getOriginalMimeType(mUniqueId, path);
     }
@@ -644,8 +564,6 @@
     public int checkRightsStatus(String path, int action) {
         if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
             throw new IllegalArgumentException("Given path or action is not valid");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         return _checkRightsStatus(mUniqueId, path, action);
     }
@@ -676,8 +594,6 @@
     public int removeRights(String path) {
         if (null == path || path.equals("")) {
             throw new IllegalArgumentException("Given path should be non null");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         return _removeRights(mUniqueId, path);
     }
@@ -706,9 +622,6 @@
      *     ERROR_UNKNOWN for failure
      */
     public int removeAllRights() {
-        if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
-        }
         int result = ERROR_UNKNOWN;
         if (null != mEventHandler) {
             Message msg = mEventHandler.obtainMessage(ACTION_REMOVE_ALL_RIGHTS);
@@ -729,8 +642,6 @@
     public int openConvertSession(String mimeType) {
         if (null == mimeType || mimeType.equals("")) {
             throw new IllegalArgumentException("Path or the mimeType should be non null");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         return _openConvertSession(mUniqueId, mimeType);
     }
@@ -750,8 +661,6 @@
     public DrmConvertedStatus convertData(int convertId, byte[] inputData) {
         if (null == inputData || 0 >= inputData.length) {
             throw new IllegalArgumentException("Given inputData should be non null");
-        } else if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
         }
         return _convertData(mUniqueId, convertId, inputData);
     }
@@ -769,28 +678,17 @@
      *     the application on which offset these signature data should be appended.
      */
     public DrmConvertedStatus closeConvertSession(int convertId) {
-        if (STATE_UNINITIALIZED == getState()) {
-            throw new IllegalStateException("Not Initialized yet");
-        }
         return _closeConvertSession(mUniqueId, convertId);
     }
 
-    private int getState() {
-        return mCurrentState;
-    }
-
     private int getEventType(int infoType) {
         int eventType = -1;
 
         switch (infoType) {
         case DrmInfoRequest.TYPE_REGISTRATION_INFO:
-            eventType = DrmEvent.TYPE_REGISTERED;
-            break;
         case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
-            eventType = DrmEvent.TYPE_UNREGISTERED;
-            break;
         case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
-            eventType = DrmEvent.TYPE_RIGHTS_ACQUIRED;
+            eventType = DrmEvent.TYPE_DRM_INFO_PROCESSED;
             break;
         }
         return eventType;
@@ -801,13 +699,9 @@
 
         switch (infoType) {
         case DrmInfoRequest.TYPE_REGISTRATION_INFO:
-            error = DrmErrorEvent.TYPE_REGISTRATION_FAILED;
-            break;
         case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
-            error = DrmErrorEvent.TYPE_UNREGISTRATION_FAILED;
-            break;
         case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
-            error = DrmErrorEvent.TYPE_RIGHTS_ACQUISITION_FAILED;
+            error = DrmErrorEvent.TYPE_PROCESS_DRM_INFO_FAILED;
             break;
         }
         return error;
@@ -822,25 +716,35 @@
      * <row_index> the index of the content in given table
      */
     private String convertUriToPath(Uri uri) {
+        String path = null;
         String scheme = uri.getScheme();
-        if (null == scheme || scheme.equals("file")) {
-            return uri.getPath();
+        if (null == scheme || scheme.equals("") || scheme.equals(ContentResolver.SCHEME_FILE)) {
+            path = uri.getPath();
+        } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
+            String[] projection = new String[] {MediaStore.MediaColumns.DATA};
+            Cursor cursor = null;
+            try {
+                cursor = mContext.getContentResolver().query(uri, projection, null, null, null);
+            } catch (SQLiteException e) {
+                throw new IllegalArgumentException("Given Uri is not formatted in a way " +
+                        "so that it can be found in media store.");
+            }
+            if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) {
+                throw new IllegalArgumentException("Given Uri could not be found in media store");
+            }
+            int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
+            path = cursor.getString(pathIndex);
+            cursor.close();
+        } else {
+            throw new IllegalArgumentException("Given Uri scheme is not supported");
         }
-        String[] projection = new String[] {MediaStore.MediaColumns.DATA};
-        Cursor cursor = mContext.getContentResolver().query(uri, projection, null, null, null);
-        if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) {
-            throw new IllegalArgumentException("Given Uri could not be found in media store");
-        }
-        int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
-        String path = cursor.getString(pathIndex);
-        cursor.close();
         return path;
     }
 
     // private native interfaces
-    private native int _loadPlugIns(int uniqueId, Object weak_this);
+    private native void _initialize(int uniqueId, Object weak_this);
 
-    private native int _unloadPlugIns(int uniqueId);
+    private native void _finalize(int uniqueId);
 
     private native void _installDrmEngine(int uniqueId, String engineFilepath);
 
diff --git a/drm/java/android/drm/DrmUtils.java b/drm/java/android/drm/DrmUtils.java
index 5e5397c..8903485 100644
--- a/drm/java/android/drm/DrmUtils.java
+++ b/drm/java/android/drm/DrmUtils.java
@@ -167,6 +167,9 @@
 
                 //Fetch Value
                 String strValue = readMultipleBytes(constraintData, valueLength, index);
+                if (strValue.equals(" ")) {
+                    strValue = "";
+                }
                 index += valueLength;
                 mMap.put(strKey, strValue);
             }
diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp
index 6158b66..e5e4547 100644
--- a/drm/jni/android_drm_DrmManagerClient.cpp
+++ b/drm/jni/android_drm_DrmManagerClient.cpp
@@ -15,7 +15,7 @@
  */
 
 //#define LOG_NDEBUG 0
-#define LOG_TAG "DrmManager-JNI"
+#define LOG_TAG "android_drm_DrmManagerClient"
 #include <utils/Log.h>
 
 #include <jni.h>
@@ -223,38 +223,32 @@
     return sp<DrmManagerClientImpl>(client);
 }
 
-static jint android_drm_DrmManagerClient_loadPlugIns(
+static void android_drm_DrmManagerClient_initialize(
         JNIEnv* env, jobject thiz, jint uniqueId, jobject weak_thiz) {
-    LOGV("load plugins - Enter");
+    LOGV("initialize - Enter");
 
     sp<DrmManagerClientImpl> drmManager = DrmManagerClientImpl::create(&uniqueId);
+    drmManager->addClient(uniqueId);
 
     // Set the listener to DrmManager
     sp<DrmManagerClient::OnInfoListener> listener = new JNIOnInfoListener(env, thiz, weak_thiz);
     drmManager->setOnInfoListener(uniqueId, listener);
 
     setDrmManagerClientImpl(env, thiz, drmManager);
-
-    LOGV("load plugins - Exit");
-    return getDrmManagerClientImpl(env, thiz)->loadPlugIns(uniqueId);
+    LOGV("initialize - Exit");
 }
 
-static jint android_drm_DrmManagerClient_unloadPlugIns(JNIEnv* env, jobject thiz, jint uniqueId) {
-    LOGV("unload plugins - Enter");
-    sp<DrmManagerClientImpl> client = getDrmManagerClientImpl(env, thiz);
-
+static void android_drm_DrmManagerClient_finalize(JNIEnv* env, jobject thiz, jint uniqueId) {
+    LOGV("finalize - Enter");
     DrmManagerClientImpl::remove(uniqueId);
-    int result = client->unloadPlugIns(uniqueId);
-    if (DRM_NO_ERROR == result) {
-        client->setOnInfoListener(uniqueId, NULL);
+    getDrmManagerClientImpl(env, thiz)->setOnInfoListener(uniqueId, NULL);
 
-        sp<DrmManagerClientImpl> oldClient = setDrmManagerClientImpl(env, thiz, NULL);
-        if (oldClient != NULL) {
-            oldClient->setOnInfoListener(uniqueId, NULL);
-        }
+    sp<DrmManagerClientImpl> oldClient = setDrmManagerClientImpl(env, thiz, NULL);
+    if (oldClient != NULL) {
+        oldClient->setOnInfoListener(uniqueId, NULL);
+        oldClient->removeClient(uniqueId);
     }
-    LOGV("unload plugins - Exit");
-    return result;
+    LOGV("finalize - Exit");
 }
 
 static jobject android_drm_DrmManagerClient_getConstraintsFromContent(
@@ -441,6 +435,7 @@
 
     if (NULL != localRef && NULL != pDrmInfoStatus) {
         int statusCode = pDrmInfoStatus->statusCode;
+        int infoType = pDrmInfoStatus->infoType;
 
         jbyteArray dataArray = NULL;
         if (NULL != pDrmInfoStatus->drmBuffer) {
@@ -461,10 +456,10 @@
 
         constructorId
             = env->GetMethodID(localRef,
-                "<init>", "(ILandroid/drm/ProcessedData;Ljava/lang/String;)V");
+                "<init>", "(IILandroid/drm/ProcessedData;Ljava/lang/String;)V");
 
-        drmInfoStatus = env->NewObject(localRef, constructorId, statusCode, processedData,
-                                env->NewStringUTF(pDrmInfoStatus->mimeType.string()));
+        drmInfoStatus = env->NewObject(localRef, constructorId, statusCode, infoType,
+                processedData, env->NewStringUTF(pDrmInfoStatus->mimeType.string()));
     }
 
     delete mData; mData = NULL;
@@ -678,11 +673,11 @@
 
 static JNINativeMethod nativeMethods[] = {
 
-    {"_loadPlugIns", "(ILjava/lang/Object;)I",
-                                    (void*)android_drm_DrmManagerClient_loadPlugIns},
+    {"_initialize", "(ILjava/lang/Object;)V",
+                                    (void*)android_drm_DrmManagerClient_initialize},
 
-    {"_unloadPlugIns", "(I)I",
-                                    (void*)android_drm_DrmManagerClient_unloadPlugIns},
+    {"_finalize", "(I)V",
+                                    (void*)android_drm_DrmManagerClient_finalize},
 
     {"_getConstraints", "(ILjava/lang/String;I)Landroid/content/ContentValues;",
                                     (void*)android_drm_DrmManagerClient_getConstraintsFromContent},
diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp
index c996994..f0439eb 100644
--- a/drm/libdrmframework/DrmManagerClient.cpp
+++ b/drm/libdrmframework/DrmManagerClient.cpp
@@ -22,36 +22,23 @@
 
 using namespace android;
 
-DrmManagerClient::DrmManagerClient() {
-    int uniqueId = 0;
-    mDrmManagerClientImpl = NULL;
-
-    mDrmManagerClientImpl = DrmManagerClientImpl::create(&uniqueId);
-    mUniqueId = uniqueId;
-
-    loadPlugIns();
+DrmManagerClient::DrmManagerClient():
+        mUniqueId(0), mDrmManagerClientImpl(NULL) {
+    mDrmManagerClientImpl = DrmManagerClientImpl::create(&mUniqueId);
+    mDrmManagerClientImpl->addClient(mUniqueId);
 }
 
 DrmManagerClient::~DrmManagerClient() {
     DrmManagerClientImpl::remove(mUniqueId);
-    unloadPlugIns();
-
+    mDrmManagerClientImpl->removeClient(mUniqueId);
     delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
 }
 
-status_t DrmManagerClient::loadPlugIns() {
-    return mDrmManagerClientImpl->loadPlugIns(mUniqueId);
-}
-
 status_t DrmManagerClient::setOnInfoListener(
                     const sp<DrmManagerClient::OnInfoListener>& infoListener) {
     return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener);
 }
 
-status_t DrmManagerClient::unloadPlugIns() {
-    return mDrmManagerClientImpl->unloadPlugIns(mUniqueId);
-}
-
 DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) {
     return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action);
 }
@@ -86,6 +73,7 @@
 }
 
 status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
+    Mutex::Autolock _l(mDecryptLock);
     return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
 }
 
@@ -128,12 +116,17 @@
     return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
 }
 
+DecryptHandle* DrmManagerClient::openDecryptSession(const char* uri) {
+    return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri);
+}
+
 status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
     return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
 }
 
 status_t DrmManagerClient::initializeDecryptUnit(
             DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
+    Mutex::Autolock _l(mDecryptLock);
     return mDrmManagerClientImpl->initializeDecryptUnit(
             mUniqueId, decryptHandle, decryptUnitId, headerInfo);
 }
@@ -141,16 +134,19 @@
 status_t DrmManagerClient::decrypt(
     DecryptHandle* decryptHandle, int decryptUnitId,
     const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
+    Mutex::Autolock _l(mDecryptLock);
     return mDrmManagerClientImpl->decrypt(
             mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
 }
 
 status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
+    Mutex::Autolock _l(mDecryptLock);
     return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
 }
 
 ssize_t DrmManagerClient::pread(
             DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) {
+    Mutex::Autolock _l(mDecryptLock);
     return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset);
 }
 
diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp
index 272adcd..b3ae9a7 100644
--- a/drm/libdrmframework/DrmManagerClientImpl.cpp
+++ b/drm/libdrmframework/DrmManagerClientImpl.cpp
@@ -46,14 +46,6 @@
     getDrmManagerService()->removeUniqueId(uniqueId);
 }
 
-DrmManagerClientImpl::DrmManagerClientImpl() {
-
-}
-
-DrmManagerClientImpl::~DrmManagerClientImpl() {
-
-}
-
 const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() {
     mMutex.lock();
     if (NULL == mDrmManagerService.get()) {
@@ -77,16 +69,12 @@
     return mDrmManagerService;
 }
 
-status_t DrmManagerClientImpl::loadPlugIns(int uniqueId) {
-    return getDrmManagerService()->loadPlugIns(uniqueId);
+void DrmManagerClientImpl::addClient(int uniqueId) {
+    getDrmManagerService()->addClient(uniqueId);
 }
 
-status_t DrmManagerClientImpl::loadPlugIns(int uniqueId, const String8& plugInDirPath) {
-    status_t status = DRM_ERROR_UNKNOWN;
-    if (EMPTY_STRING != plugInDirPath) {
-        status = getDrmManagerService()->loadPlugIns(uniqueId, plugInDirPath);
-    }
-    return status;
+void DrmManagerClientImpl::removeClient(int uniqueId) {
+    getDrmManagerService()->removeClient(uniqueId);
 }
 
 status_t DrmManagerClientImpl::setOnInfoListener(
@@ -96,10 +84,6 @@
     return getDrmManagerService()->setDrmServiceListener(uniqueId, this);
 }
 
-status_t DrmManagerClientImpl::unloadPlugIns(int uniqueId) {
-    return getDrmManagerService()->unloadPlugIns(uniqueId);
-}
-
 status_t DrmManagerClientImpl::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
     status_t status = DRM_ERROR_UNKNOWN;
     if (EMPTY_STRING != drmEngineFile) {
@@ -251,6 +235,14 @@
     return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length);
 }
 
+DecryptHandle* DrmManagerClientImpl::openDecryptSession(int uniqueId, const char* uri) {
+    DecryptHandle* handle = NULL;
+    if (NULL != uri) {
+        handle = getDrmManagerService()->openDecryptSession(uniqueId, uri);
+    }
+    return handle;
+}
+
 status_t DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
     status_t status = DRM_ERROR_UNKNOWN;
     if (NULL != decryptHandle) {
diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/libdrmframework/include/DrmManager.h
index dc3e460..d782f5b 100644
--- a/drm/libdrmframework/include/DrmManager.h
+++ b/drm/libdrmframework/include/DrmManager.h
@@ -57,15 +57,19 @@
 
     void removeUniqueId(int uniqueId);
 
-    status_t loadPlugIns(int uniqueId);
+    void addClient(int uniqueId);
 
-    status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
+    void removeClient(int uniqueId);
+
+    status_t loadPlugIns();
+
+    status_t loadPlugIns(const String8& plugInDirPath);
+
+    status_t unloadPlugIns();
 
     status_t setDrmServiceListener(
             int uniqueId, const sp<IDrmServiceListener>& drmServiceListener);
 
-    status_t unloadPlugIns(int uniqueId);
-
     status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
 
     DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
@@ -107,6 +111,8 @@
 
     DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
 
+    DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+
     status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
 
     status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
@@ -129,12 +135,8 @@
 
     String8 getSupportedPlugInIdFromPath(int uniqueId, const String8& path);
 
-    void populate(int uniqueId);
-
     bool canHandle(int uniqueId, const String8& path);
 
-    void initializePlugIns(int uniqueId);
-
 private:
     static Vector<int> mUniqueIdVector;
     static const String8 EMPTY_STRING;
diff --git a/drm/libdrmframework/include/DrmManagerClientImpl.h b/drm/libdrmframework/include/DrmManagerClientImpl.h
index 492c7f5..1c6be46 100644
--- a/drm/libdrmframework/include/DrmManagerClientImpl.h
+++ b/drm/libdrmframework/include/DrmManagerClientImpl.h
@@ -35,36 +35,29 @@
  */
 class DrmManagerClientImpl : public BnDrmServiceListener {
 private:
-    DrmManagerClientImpl();
+    DrmManagerClientImpl() { }
 
 public:
     static DrmManagerClientImpl* create(int* pUniqueId);
 
     static void remove(int uniqueId);
 
-    virtual ~DrmManagerClientImpl();
+    virtual ~DrmManagerClientImpl() { }
 
 public:
     /**
-     * Initialize DRM Manager
-     *     load available plug-ins from default plugInDirPath
+     * Adds the client respective to given unique id.
      *
      * @param[in] uniqueId Unique identifier for a session
-     * @return status_t
-     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
      */
-    status_t loadPlugIns(int uniqueId);
+    void addClient(int uniqueId);
 
     /**
-     * Finalize DRM Manager
-     *     release resources associated with each plug-in
-     *     unload all plug-ins and etc.
+     * Removes the client respective to given unique id.
      *
      * @param[in] uniqueId Unique identifier for a session
-     * @return status_t
-     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
      */
-    status_t unloadPlugIns(int uniqueId);
+    void removeClient(int uniqueId);
 
     /**
      * Register a callback to be invoked when the caller required to
@@ -301,6 +294,16 @@
     DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
 
     /**
+     * Open the decrypt session to decrypt the given protected content
+     *
+     * @param[in] uniqueId Unique identifier for a session
+     * @param[in] uri Path of the protected content to be decrypted
+     * @return
+     *     Handle for the decryption session
+     */
+    DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+
+    /**
      * Close the decrypt session for the given handle
      *
      * @param[in] uniqueId Unique identifier for a session
@@ -379,17 +382,6 @@
 
 private:
     /**
-     * Initialize DRM Manager
-     *     load available plug-ins from plugInDirPath
-     *
-     * @param[in] uniqueId Unique identifier for a session
-     * @param[in] plugInDirPath Directory from where to load plug-ins
-     * @return status_t
-     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
-     */
-    status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
-
-    /**
      * Install new DRM Engine Plug-in at the runtime
      *
      * @param[in] uniqueId Unique identifier for a session
diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h
index f455e15..4a3aeae 100644
--- a/drm/libdrmframework/include/DrmManagerService.h
+++ b/drm/libdrmframework/include/DrmManagerService.h
@@ -50,15 +50,13 @@
 
     void removeUniqueId(int uniqueId);
 
-    status_t loadPlugIns(int uniqueId);
+    void addClient(int uniqueId);
 
-    status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
+    void removeClient(int uniqueId);
 
     status_t setDrmServiceListener(
             int uniqueId, const sp<IDrmServiceListener>& drmServiceListener);
 
-    status_t unloadPlugIns(int uniqueId);
-
     status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
 
     DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
@@ -100,6 +98,8 @@
 
     DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
 
+    DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+
     status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
 
     status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/libdrmframework/include/IDrmManagerService.h
index 5c668ed..1275488 100644
--- a/drm/libdrmframework/include/IDrmManagerService.h
+++ b/drm/libdrmframework/include/IDrmManagerService.h
@@ -46,10 +46,9 @@
     enum {
         ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION,
         REMOVE_UNIQUEID,
-        LOAD_PLUGINS,
-        LOAD_PLUGINS_FROM_PATH,
+        ADD_CLIENT,
+        REMOVE_CLIENT,
         SET_DRM_SERVICE_LISTENER,
-        UNLOAD_PLUGINS,
         INSTALL_DRM_ENGINE,
         GET_CONSTRAINTS_FROM_CONTENT,
         CAN_HANDLE,
@@ -69,6 +68,7 @@
         CLOSE_CONVERT_SESSION,
         GET_ALL_SUPPORT_INFO,
         OPEN_DECRYPT_SESSION,
+        OPEN_DECRYPT_SESSION_FROM_URI,
         CLOSE_DECRYPT_SESSION,
         INITIALIZE_DECRYPT_UNIT,
         DECRYPT,
@@ -84,15 +84,13 @@
 
     virtual void removeUniqueId(int uniqueId) = 0;
 
-    virtual status_t loadPlugIns(int uniqueId) = 0;
+    virtual void addClient(int uniqueId) = 0;
 
-    virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath) = 0;
+    virtual void removeClient(int uniqueId) = 0;
 
     virtual status_t setDrmServiceListener(
             int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0;
 
-    virtual status_t unloadPlugIns(int uniqueId) = 0;
-
     virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile) = 0;
 
     virtual DrmConstraints* getConstraints(
@@ -140,6 +138,8 @@
 
     virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0;
 
+    virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri) = 0;
+
     virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
 
     virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
@@ -168,15 +168,13 @@
 
     virtual void removeUniqueId(int uniqueId);
 
-    virtual status_t loadPlugIns(int uniqueId);
+    virtual void addClient(int uniqueId);
 
-    virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
+    virtual void removeClient(int uniqueId);
 
     virtual status_t setDrmServiceListener(
             int uniqueId, const sp<IDrmServiceListener>& infoListener);
 
-    virtual status_t unloadPlugIns(int uniqueId);
-
     virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
 
     virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
@@ -221,6 +219,8 @@
 
     virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
 
+    virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+
     virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
 
     virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
index b355534..5851af5 100644
--- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
+++ b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
@@ -80,6 +80,9 @@
     status_t openDecryptSession(
             int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
 
+    status_t openDecryptSession(
+            int uniqueId, DecryptHandle* decryptHandle, const char* uri);
+
     status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
 
     status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
@@ -355,6 +358,18 @@
             int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0;
 
     /**
+     * Open the decrypt session to decrypt the given protected content
+     *
+     * @param[in] uniqueId Unique identifier for a session
+     * @param[in] decryptHandle Handle for the current decryption session
+     * @param[in] uri Path of the protected content to be decrypted
+     * @return
+     *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
+     */
+    virtual status_t onOpenDecryptSession(
+            int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
+
+    /**
      * Close the decrypt session for the given handle
      *
      * @param[in] uniqueId Unique identifier for a session
diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
index b711500..cc03ef2 100644
--- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h
+++ b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
@@ -315,6 +315,18 @@
         int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0;
 
     /**
+     * Open the decrypt session to decrypt the given protected content
+     *
+     * @param[in] uniqueId Unique identifier for a session
+     * @param[in] decryptHandle Handle for the current decryption session
+     * @param[in] uri Path of the protected content to be decrypted
+     * @return
+     *     DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
+     */
+    virtual status_t openDecryptSession(
+        int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
+
+    /**
      * Close the decrypt session for the given handle
      *
      * @param[in] uniqueId Unique identifier for a session
diff --git a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
index eed1628..ddb7fd3 100644
--- a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
+++ b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
@@ -74,6 +74,9 @@
     status_t onOpenDecryptSession(
             int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
 
+    status_t onOpenDecryptSession(
+            int uniqueId, DecryptHandle* decryptHandle, const char* uri);
+
     status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
 
     status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
index 4c7714d..41f8e91 100644
--- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
+++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
@@ -74,14 +74,14 @@
         switch (drmInfo->getInfoType()) {
         case DrmInfoRequest::TYPE_REGISTRATION_INFO: {
             const DrmBuffer* emptyBuffer = new DrmBuffer();
-            drmInfoStatus
-                = new DrmInfoStatus(DrmInfoStatus::STATUS_OK, emptyBuffer, drmInfo->getMimeType());
+            drmInfoStatus = new DrmInfoStatus(DrmInfoStatus::STATUS_OK,
+                    DrmInfoRequest::TYPE_REGISTRATION_INFO, emptyBuffer, drmInfo->getMimeType());
             break;
         }
         case DrmInfoRequest::TYPE_UNREGISTRATION_INFO: {
             const DrmBuffer* emptyBuffer = new DrmBuffer();
-            drmInfoStatus
-                = new DrmInfoStatus(DrmInfoStatus::STATUS_OK, emptyBuffer, drmInfo->getMimeType());
+            drmInfoStatus = new DrmInfoStatus(DrmInfoStatus::STATUS_OK,
+                    DrmInfoRequest::TYPE_UNREGISTRATION_INFO, emptyBuffer, drmInfo->getMimeType());
             break;
         }
         case DrmInfoRequest::TYPE_RIGHTS_ACQUISITION_INFO: {
@@ -91,8 +91,8 @@
             data = new char[bufferSize];
             memcpy(data, licenseString.string(), bufferSize);
             const DrmBuffer* buffer = new DrmBuffer(data, bufferSize);
-            drmInfoStatus
-                = new DrmInfoStatus(DrmInfoStatus::STATUS_OK, buffer, drmInfo->getMimeType());
+            drmInfoStatus = new DrmInfoStatus(DrmInfoStatus::STATUS_OK,
+                    DrmInfoRequest::TYPE_RIGHTS_ACQUISITION_INFO, buffer, drmInfo->getMimeType());
             break;
         }
         }
@@ -243,6 +243,11 @@
     return DRM_ERROR_CANNOT_HANDLE;
 }
 
+status_t DrmPassthruPlugIn::onOpenDecryptSession(
+            int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
+    return DRM_ERROR_CANNOT_HANDLE;
+}
+
 status_t DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
     LOGD("DrmPassthruPlugIn::onCloseDecryptSession() : %d", uniqueId);
     if (NULL != decryptHandle) {
diff --git a/include/drm/DrmInfoEvent.h b/include/drm/DrmInfoEvent.h
index c722bd3..7b409ff 100644
--- a/include/drm/DrmInfoEvent.h
+++ b/include/drm/DrmInfoEvent.h
@@ -59,8 +59,8 @@
     //! TYPE_NO_INTERNET_CONNECTION, when the Internet connection is missing and no attempt
     //! can be made to renew rights
     static const int TYPE_NO_INTERNET_CONNECTION = 2005;
-    //! TYPE_REGISTRATION_FAILED, when registration with server failed.
-    static const int TYPE_REGISTRATION_FAILED = 2006;
+    //! TYPE_PROCESS_DRM_INFO_FAILED, when failed to process DrmInfo.
+    static const int TYPE_PROCESS_DRM_INFO_FAILED = 2006;
 
 public:
     /**
diff --git a/include/drm/DrmInfoStatus.h b/include/drm/DrmInfoStatus.h
index 806aea1..88c0f40 100644
--- a/include/drm/DrmInfoStatus.h
+++ b/include/drm/DrmInfoStatus.h
@@ -41,10 +41,11 @@
      * Constructor for DrmInfoStatus
      *
      * @param[in] _statusCode Status of the communication
+     * @param[in] _infoType Type of the DRM information processed
      * @param[in] _drmBuffer Rights information
      * @param[in] _mimeType MIME type
      */
-    DrmInfoStatus(int _statusCode, const DrmBuffer* _drmBuffer, const String8& _mimeType);
+    DrmInfoStatus(int _statusCode, int _infoType, const DrmBuffer* _drmBuffer, const String8& _mimeType);
 
     /**
      * Destructor for DrmInfoStatus
@@ -55,6 +56,7 @@
 
 public:
     int statusCode;
+    int infoType;
     const DrmBuffer* drmBuffer;
     String8 mimeType;
 };
diff --git a/include/drm/DrmManagerClient.h b/include/drm/DrmManagerClient.h
index c2ad084..5963c42 100644
--- a/include/drm/DrmManagerClient.h
+++ b/include/drm/DrmManagerClient.h
@@ -17,6 +17,7 @@
 #ifndef __DRM_MANAGER_CLIENT_H__
 #define __DRM_MANAGER_CLIENT_H__
 
+#include <utils/threads.h>
 #include <binder/IInterface.h>
 #include "drm_framework_common.h"
 
@@ -67,6 +68,15 @@
     DecryptHandle* openDecryptSession(int fd, int offset, int length);
 
     /**
+     * Open the decrypt session to decrypt the given protected content
+     *
+     * @param[in] uri Path of the protected content to be decrypted
+     * @return
+     *     Handle for the decryption session
+     */
+    DecryptHandle* openDecryptSession(const char* uri);
+
+    /**
      * Close the decrypt session for the given handle
      *
      * @param[in] decryptHandle Handle for the decryption session
@@ -339,27 +349,8 @@
     status_t getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray);
 
 private:
-    /**
-     * Initialize DRM Manager
-     *     load available plug-ins from default plugInDirPath
-     *
-     * @return status_t
-     *     Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
-     */
-    status_t loadPlugIns();
-
-    /**
-     * Finalize DRM Manager
-     *    release resources associated with each plug-in
-     *    unload all plug-ins and etc.
-     *
-     * @return status_t
-     *    Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
-     */
-    status_t unloadPlugIns();
-
-private:
     int mUniqueId;
+    Mutex mDecryptLock;
     DrmManagerClientImpl* mDrmManagerClientImpl;
 };
 
diff --git a/include/ui/KeycodeLabels.h b/include/ui/KeycodeLabels.h
index ef2b6b3..73f5863 100755
--- a/include/ui/KeycodeLabels.h
+++ b/include/ui/KeycodeLabels.h
@@ -188,6 +188,7 @@
     { "NUMPAD_EQUALS", 161 },
     { "NUMPAD_LEFT_PAREN", 162 },
     { "NUMPAD_RIGHT_PAREN", 163 },
+    { "VOLUME_MUTE", 164 },
 
     // NOTE: If you add a new keycode here you must also add it to several other files.
     //       Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
diff --git a/libs/ui/Input.cpp b/libs/ui/Input.cpp
index 811edaf..944a79b 100644
--- a/libs/ui/Input.cpp
+++ b/libs/ui/Input.cpp
@@ -33,6 +33,7 @@
         case AKEYCODE_ENDCALL:
         case AKEYCODE_VOLUME_UP:
         case AKEYCODE_VOLUME_DOWN:
+        case AKEYCODE_VOLUME_MUTE:
         case AKEYCODE_POWER:
         case AKEYCODE_CAMERA:
         case AKEYCODE_HEADSETHOOK:
@@ -40,11 +41,14 @@
         case AKEYCODE_NOTIFICATION:
         case AKEYCODE_FOCUS:
         case AKEYCODE_SEARCH:
+        case AKEYCODE_MEDIA_PLAY:
+        case AKEYCODE_MEDIA_PAUSE:
         case AKEYCODE_MEDIA_PLAY_PAUSE:
         case AKEYCODE_MEDIA_STOP:
         case AKEYCODE_MEDIA_NEXT:
         case AKEYCODE_MEDIA_PREVIOUS:
         case AKEYCODE_MEDIA_REWIND:
+        case AKEYCODE_MEDIA_RECORD:
         case AKEYCODE_MEDIA_FAST_FORWARD:
         case AKEYCODE_MUTE:
             return true;
@@ -67,14 +71,18 @@
         case AKEYCODE_ENDCALL:
         case AKEYCODE_VOLUME_UP:
         case AKEYCODE_VOLUME_DOWN:
+        case AKEYCODE_VOLUME_MUTE:
         case AKEYCODE_MUTE:
         case AKEYCODE_POWER:
         case AKEYCODE_HEADSETHOOK:
+        case AKEYCODE_MEDIA_PLAY:
+        case AKEYCODE_MEDIA_PAUSE:
         case AKEYCODE_MEDIA_PLAY_PAUSE:
         case AKEYCODE_MEDIA_STOP:
         case AKEYCODE_MEDIA_NEXT:
         case AKEYCODE_MEDIA_PREVIOUS:
         case AKEYCODE_MEDIA_REWIND:
+        case AKEYCODE_MEDIA_RECORD:
         case AKEYCODE_MEDIA_FAST_FORWARD:
         case AKEYCODE_CAMERA:
         case AKEYCODE_FOCUS:
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index a02c154..f9c0b91 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -619,6 +619,38 @@
 bool InputDispatcher::dispatchKeyLocked(
         nsecs_t currentTime, KeyEntry* entry, nsecs_t keyRepeatTimeout,
         DropReason* dropReason, nsecs_t* nextWakeupTime) {
+    // Preprocessing.
+    if (! entry->dispatchInProgress) {
+        if (entry->repeatCount == 0
+                && entry->action == AKEY_EVENT_ACTION_DOWN
+                && (entry->policyFlags & POLICY_FLAG_TRUSTED)
+                && !entry->isInjected()) {
+            if (mKeyRepeatState.lastKeyEntry
+                    && mKeyRepeatState.lastKeyEntry->keyCode == entry->keyCode) {
+                // We have seen two identical key downs in a row which indicates that the device
+                // driver is automatically generating key repeats itself.  We take note of the
+                // repeat here, but we disable our own next key repeat timer since it is clear that
+                // we will not need to synthesize key repeats ourselves.
+                entry->repeatCount = mKeyRepeatState.lastKeyEntry->repeatCount + 1;
+                resetKeyRepeatLocked();
+                mKeyRepeatState.nextRepeatTime = LONG_LONG_MAX; // don't generate repeats ourselves
+            } else {
+                // Not a repeat.  Save key down state in case we do see a repeat later.
+                resetKeyRepeatLocked();
+                mKeyRepeatState.nextRepeatTime = entry->eventTime + keyRepeatTimeout;
+            }
+            mKeyRepeatState.lastKeyEntry = entry;
+            entry->refCount += 1;
+        } else if (! entry->syntheticRepeat) {
+            resetKeyRepeatLocked();
+        }
+
+        entry->dispatchInProgress = true;
+        resetTargetsLocked();
+
+        logOutboundKeyDetailsLocked("dispatchKey - ", entry);
+    }
+
     // Give the policy a chance to intercept the key.
     if (entry->interceptKeyResult == KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN) {
         if (entry->policyFlags & POLICY_FLAG_PASS_TO_USER) {
@@ -647,38 +679,6 @@
         return true;
     }
 
-    // Preprocessing.
-    if (! entry->dispatchInProgress) {
-        logOutboundKeyDetailsLocked("dispatchKey - ", entry);
-
-        if (entry->repeatCount == 0
-                && entry->action == AKEY_EVENT_ACTION_DOWN
-                && (entry->policyFlags & POLICY_FLAG_TRUSTED)
-                && !entry->isInjected()) {
-            if (mKeyRepeatState.lastKeyEntry
-                    && mKeyRepeatState.lastKeyEntry->keyCode == entry->keyCode) {
-                // We have seen two identical key downs in a row which indicates that the device
-                // driver is automatically generating key repeats itself.  We take note of the
-                // repeat here, but we disable our own next key repeat timer since it is clear that
-                // we will not need to synthesize key repeats ourselves.
-                entry->repeatCount = mKeyRepeatState.lastKeyEntry->repeatCount + 1;
-                resetKeyRepeatLocked();
-                mKeyRepeatState.nextRepeatTime = LONG_LONG_MAX; // don't generate repeats ourselves
-            } else {
-                // Not a repeat.  Save key down state in case we do see a repeat later.
-                resetKeyRepeatLocked();
-                mKeyRepeatState.nextRepeatTime = entry->eventTime + keyRepeatTimeout;
-            }
-            mKeyRepeatState.lastKeyEntry = entry;
-            entry->refCount += 1;
-        } else if (! entry->syntheticRepeat) {
-            resetKeyRepeatLocked();
-        }
-
-        entry->dispatchInProgress = true;
-        resetTargetsLocked();
-    }
-
     // Identify targets.
     if (! mCurrentInputTargetsValid) {
         int32_t injectionResult = findFocusedWindowTargetsLocked(currentTime,
@@ -705,16 +705,24 @@
 #if DEBUG_OUTBOUND_EVENT_DETAILS
     LOGD("%seventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, "
             "action=0x%x, flags=0x%x, keyCode=0x%x, scanCode=0x%x, metaState=0x%x, "
-            "downTime=%lld",
+            "repeatCount=%d, downTime=%lld",
             prefix,
             entry->eventTime, entry->deviceId, entry->source, entry->policyFlags,
             entry->action, entry->flags, entry->keyCode, entry->scanCode, entry->metaState,
-            entry->downTime);
+            entry->repeatCount, entry->downTime);
 #endif
 }
 
 bool InputDispatcher::dispatchMotionLocked(
         nsecs_t currentTime, MotionEntry* entry, DropReason* dropReason, nsecs_t* nextWakeupTime) {
+    // Preprocessing.
+    if (! entry->dispatchInProgress) {
+        entry->dispatchInProgress = true;
+        resetTargetsLocked();
+
+        logOutboundMotionDetailsLocked("dispatchMotion - ", entry);
+    }
+
     // Clean up if dropping the event.
     if (*dropReason != DROP_REASON_NOT_DROPPED) {
         resetTargetsLocked();
@@ -723,14 +731,6 @@
         return true;
     }
 
-    // Preprocessing.
-    if (! entry->dispatchInProgress) {
-        logOutboundMotionDetailsLocked("dispatchMotion - ", entry);
-
-        entry->dispatchInProgress = true;
-        resetTargetsLocked();
-    }
-
     bool isPointerEvent = entry->source & AINPUT_SOURCE_CLASS_POINTER;
 
     // Identify targets.
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 8c3efff..3f6b7a2 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -384,7 +384,7 @@
     private MyMediaScannerClient mClient = new MyMediaScannerClient();
 
     private boolean isDrmEnabled() {
-        String prop = System.getProperty("drm.service.enabled");
+        String prop = SystemProperties.get("drm.service.enabled");
         return prop != null && prop.equals("true");
     }
     
diff --git a/media/java/android/media/videoeditor/AudioTrack.java b/media/java/android/media/videoeditor/AudioTrack.java
index 573208a..d02709e 100755
--- a/media/java/android/media/videoeditor/AudioTrack.java
+++ b/media/java/android/media/videoeditor/AudioTrack.java
@@ -17,6 +17,7 @@
 package android.media.videoeditor;

 

 import java.io.IOException;

+import java.lang.ref.SoftReference;

 

 /**

  * This class allows to handle an audio track. This audio file is mixed with the

@@ -49,7 +50,7 @@
     // The audio waveform filename

     private String mAudioWaveformFilename;

     // The audio waveform data

-    private WaveformData mWaveformData;

+    private SoftReference<WaveformData> mWaveformData;

 

     /**

      * An object of this type cannot be instantiated by using the default

@@ -165,7 +166,8 @@
 

         mAudioWaveformFilename = audioWaveformFilename;

         if (audioWaveformFilename != null) {

-            mWaveformData = new WaveformData(audioWaveformFilename);

+            mWaveformData =

+                new SoftReference<WaveformData>(new WaveformData(audioWaveformFilename));

         } else {

             mWaveformData = null;

         }

@@ -424,7 +426,7 @@
             throws IOException {

         // TODO: Set mAudioWaveformFilename at the end once the extract is

         // complete

-        mWaveformData = new WaveformData(mAudioWaveformFilename);

+        mWaveformData = new SoftReference<WaveformData>(new WaveformData(mAudioWaveformFilename));

     }

 

     /**

@@ -448,7 +450,20 @@
      * @return The waveform data

      */

     public WaveformData getWaveformData() {

-        return mWaveformData;

+        if (mWaveformData == null) {

+            return null;

+        }

+

+        WaveformData waveformData = mWaveformData.get();

+        if (waveformData != null) {

+            return waveformData;

+        } else if (mAudioWaveformFilename != null) {

+            waveformData = new WaveformData(mAudioWaveformFilename);

+            mWaveformData = new SoftReference<WaveformData>(waveformData);

+            return waveformData;

+        } else {

+            return null;

+        }

     }

 

     /*

diff --git a/media/java/android/media/videoeditor/MediaVideoItem.java b/media/java/android/media/videoeditor/MediaVideoItem.java
index 1fa98e7..c1abf78 100755
--- a/media/java/android/media/videoeditor/MediaVideoItem.java
+++ b/media/java/android/media/videoeditor/MediaVideoItem.java
@@ -17,6 +17,7 @@
 package android.media.videoeditor;

 

 import java.io.IOException;

+import java.lang.ref.SoftReference;

 

 import android.graphics.Bitmap;

 import android.view.SurfaceHolder;

@@ -47,7 +48,7 @@
     private boolean mMuted;

     private String mAudioWaveformFilename;

     // The audio waveform data

-    private WaveformData mWaveformData;

+    private SoftReference<WaveformData> mWaveformData;

 

     /**

      * An object of this type cannot be instantiated with a default constructor

@@ -118,7 +119,8 @@
         mMuted = muted;

         mAudioWaveformFilename = audioWaveformFilename;

         if (audioWaveformFilename != null) {

-            mWaveformData = new WaveformData(audioWaveformFilename);

+            mWaveformData =

+                new SoftReference<WaveformData>(new WaveformData(audioWaveformFilename));

         } else {

             mWaveformData = null;

         }

@@ -293,7 +295,7 @@
     public void extractAudioWaveform(ExtractAudioWaveformProgressListener listener)

             throws IOException {

         // TODO: Set mAudioWaveformFilename at the end once the export is complete

-        mWaveformData = new WaveformData(mAudioWaveformFilename);

+        mWaveformData = new SoftReference<WaveformData>(new WaveformData(mAudioWaveformFilename));

     }

 

     /**

@@ -315,7 +317,20 @@
      * @return The waveform data

      */

     public WaveformData getWaveformData() {

-        return mWaveformData;

+        if (mWaveformData == null) {

+            return null;

+        }

+

+        WaveformData waveformData = mWaveformData.get();

+        if (waveformData != null) {

+            return waveformData;

+        } else if (mAudioWaveformFilename != null) {

+            waveformData = new WaveformData(mAudioWaveformFilename);

+            mWaveformData = new SoftReference<WaveformData>(waveformData);

+            return waveformData;

+        } else {

+            return null;

+        }

     }

 

     /**

diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 6954e36..ca90c0c 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -333,14 +333,9 @@
     }
 
     dataSource->getDrmInfo(&mDecryptHandle, &mDrmManagerClient);
-    if (mDecryptHandle != NULL) {
-        if (RightsStatus::RIGHTS_VALID == mDecryptHandle->status) {
-            if (DecryptApiType::CONTAINER_BASED == mDecryptHandle->decryptApiType) {
-                mDrmManagerClient->consumeRights(mDecryptHandle, Action::PLAY, true);
-            }
-        } else {
-            notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE);
-        }
+    if (mDecryptHandle != NULL
+            && RightsStatus::RIGHTS_VALID != mDecryptHandle->status) {
+        notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE);
     }
 
     return setDataSource_l(extractor);
@@ -408,11 +403,6 @@
     }
 
     mExtractorFlags = extractor->flags();
-    if (mDecryptHandle != NULL) {
-        if (DecryptApiType::ELEMENTARY_STREAM_BASED == mDecryptHandle->decryptApiType) {
-            mDrmManagerClient->consumeRights(mDecryptHandle, Action::PLAY, true);
-        }
-    }
 
     return OK;
 }
@@ -426,8 +416,6 @@
     if (mDecryptHandle != NULL) {
             mDrmManagerClient->setPlaybackStatus(mDecryptHandle,
                     Playback::STOP, 0);
-            mDrmManagerClient->consumeRights(mDecryptHandle,
-                    Action::PLAY, false);
             mDecryptHandle = NULL;
             mDrmManagerClient = NULL;
     }
@@ -1679,14 +1667,9 @@
     }
 
     dataSource->getDrmInfo(&mDecryptHandle, &mDrmManagerClient);
-    if (mDecryptHandle != NULL) {
-        if (RightsStatus::RIGHTS_VALID == mDecryptHandle->status) {
-            if (DecryptApiType::CONTAINER_BASED == mDecryptHandle->decryptApiType) {
-                mDrmManagerClient->consumeRights(mDecryptHandle, Action::PLAY, true);
-            }
-        } else {
-            notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE);
-        }
+    if (mDecryptHandle != NULL
+            && RightsStatus::RIGHTS_VALID != mDecryptHandle->status) {
+        notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE);
     }
 
     return setDataSource_l(extractor);
diff --git a/native/include/android/keycodes.h b/native/include/android/keycodes.h
index 3fcf977..11142537 100644
--- a/native/include/android/keycodes.h
+++ b/native/include/android/keycodes.h
@@ -207,7 +207,7 @@
     AKEYCODE_NUMPAD_EQUALS   = 161,
     AKEYCODE_NUMPAD_LEFT_PAREN = 162,
     AKEYCODE_NUMPAD_RIGHT_PAREN = 163,
-
+    AKEYCODE_VOLUME_MUTE     = 164,
 
     // NOTE: If you add a new keycode here you must also add it to several other files.
     //       Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
index 0f1aa4e..34dbace 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
@@ -170,7 +170,8 @@
                 }
 
                 case KeyEvent.KEYCODE_VOLUME_UP:
-                case KeyEvent.KEYCODE_VOLUME_DOWN: {
+                case KeyEvent.KEYCODE_VOLUME_DOWN:
+                case KeyEvent.KEYCODE_VOLUME_MUTE: {
                     synchronized (this) {
                         if (mAudioManager == null) {
                             mAudioManager = (AudioManager) getContext().getSystemService(
@@ -179,6 +180,7 @@
                     }
                     // Volume buttons should only function for music.
                     if (mAudioManager.isMusicActive()) {
+                        // TODO: Actually handle MUTE.
                         mAudioManager.adjustStreamVolume(
                                     AudioManager.STREAM_MUSIC,
                                     keyCode == KeyEvent.KEYCODE_VOLUME_UP
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index c870503..42b73b9 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -786,6 +786,7 @@
         switch (keyCode) {
             case KeyEvent.KEYCODE_VOLUME_UP:
             case KeyEvent.KEYCODE_VOLUME_DOWN:
+            case KeyEvent.KEYCODE_VOLUME_MUTE:
             case KeyEvent.KEYCODE_MUTE:
             case KeyEvent.KEYCODE_HEADSETHOOK:
             case KeyEvent.KEYCODE_MEDIA_PLAY:
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index e944f9d..cd88821 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -1230,7 +1230,8 @@
         
         switch (keyCode) {
             case KeyEvent.KEYCODE_VOLUME_UP:
-            case KeyEvent.KEYCODE_VOLUME_DOWN: {
+            case KeyEvent.KEYCODE_VOLUME_DOWN:
+            case KeyEvent.KEYCODE_VOLUME_MUTE: {
                 AudioManager audioManager = (AudioManager) getContext().getSystemService(
                         Context.AUDIO_SERVICE);
                 if (audioManager != null) {
@@ -1238,6 +1239,7 @@
                      * Adjust the volume in on key down since it is more
                      * responsive to the user.
                      */
+                    // TODO: Actually handle MUTE.
                     audioManager.adjustSuggestedStreamVolume(
                             keyCode == KeyEvent.KEYCODE_VOLUME_UP
                                     ? AudioManager.ADJUST_RAISE
@@ -1405,7 +1407,8 @@
         
         switch (keyCode) {
             case KeyEvent.KEYCODE_VOLUME_UP:
-            case KeyEvent.KEYCODE_VOLUME_DOWN: {
+            case KeyEvent.KEYCODE_VOLUME_DOWN:
+            case KeyEvent.KEYCODE_VOLUME_MUTE: {
                 if (!event.isCanceled()) {
                     AudioManager audioManager = (AudioManager) getContext().getSystemService(
                             Context.AUDIO_SERVICE);
@@ -1414,6 +1417,7 @@
                          * Play a sound. This is done on key up since we don't want the
                          * sound to play when a user holds down volume down to mute.
                          */
+                        // TODO: Actually handle MUTE.
                         audioManager.adjustSuggestedStreamVolume(
                                 AudioManager.ADJUST_SAME,
                                 mVolumeControlStreamType,
@@ -1720,6 +1724,7 @@
              * cancel the sound
              */
             if (keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_UP
+                    && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE
                     && mVolumeKeyUpTime + VolumePanel.PLAY_SOUND_DELAY
                             > SystemClock.uptimeMillis()) {
                 /*
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index e950ae5..af1bf59 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -1877,6 +1877,7 @@
             // since audio is playing, we shouldn't have to hold a wake lock
             // during the call, but we do it as a precaution for the rare possibility
             // that the music stops right before we call this
+            // TODO: Actually handle MUTE.
             mBroadcastWakeLock.acquire();
             audioService.adjustStreamVolume(stream,
                 keycode == KeyEvent.KEYCODE_VOLUME_UP
@@ -1949,7 +1950,8 @@
         // Handle special keys.
         switch (keyCode) {
             case KeyEvent.KEYCODE_VOLUME_DOWN:
-            case KeyEvent.KEYCODE_VOLUME_UP: {
+            case KeyEvent.KEYCODE_VOLUME_UP:
+            case KeyEvent.KEYCODE_VOLUME_MUTE: {
                 if (down) {
                     ITelephony telephonyService = getTelephonyService();
                     if (telephonyService != null) {
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 55ebded..1cbc8324 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -687,7 +687,7 @@
                     }
                 }
                 if (touchedWin != null) {
-                    if (DEBUG_DRAG) {
+                    if (false && DEBUG_DRAG) {
                         Slog.d(TAG, "sending DRAG_LOCATION to " + touchedWin);
                     }
                     DragEvent evt = DragEvent.obtain(DragEvent.ACTION_DRAG_LOCATION,
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
index 6627d37..2b54711 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
@@ -19,10 +19,22 @@
 import com.android.layoutlib.api.ILayoutLog;
 import com.android.layoutlib.bridge.DelegateManager;
 
+import android.graphics.Paint_Delegate.FontInfo;
+import android.text.TextUtils;
+
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Composite;
 import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
+import java.util.List;
 import java.util.Stack;
 
+
 /**
  * Delegate implementing the native methods of android.graphics.Canvas
  *
@@ -95,80 +107,177 @@
     }
 
     /*package*/ static int getWidth(Canvas thisCanvas) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return 0;
+        }
+
+        return canvasDelegate.mBufferedImage.getWidth();
     }
 
     /*package*/ static int getHeight(Canvas thisCanvas) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return 0;
+        }
+
+        return canvasDelegate.mBufferedImage.getHeight();
     }
 
     /*package*/ static void translate(Canvas thisCanvas, float dx, float dy) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return;
+        }
+
+        canvasDelegate.getGraphics2d().translate(dx, dy);
     }
 
     /*package*/ static void rotate(Canvas thisCanvas, float degrees) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return;
+        }
+
+        canvasDelegate.getGraphics2d().rotate(Math.toRadians(degrees));
     }
 
     /*package*/ static void scale(Canvas thisCanvas, float sx, float sy) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return;
+        }
+
+        canvasDelegate.getGraphics2d().scale(sx, sy);
     }
 
-    /*package*/ static void skew(Canvas thisCanvas, float sx, float sy) {
-        // FIXME
-        throw new UnsupportedOperationException();
+    /*package*/ static void skew(Canvas thisCanvas, float kx, float ky) {
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return;
+        }
+
+        // get the current top graphics2D object.
+        Graphics2D g = canvasDelegate.getGraphics2d();
+
+        // get its current matrix
+        AffineTransform currentTx = g.getTransform();
+        // get the AffineTransform for the given skew.
+        float[] mtx = Matrix_Delegate.getSkew(kx, ky);
+        AffineTransform matrixTx = Matrix_Delegate.getAffineTransform(mtx);
+
+        // combine them so that the given matrix is applied after.
+        currentTx.preConcatenate(matrixTx);
+
+        // give it to the graphics2D as a new matrix replacing all previous transform
+        g.setTransform(currentTx);
     }
 
     /*package*/ static boolean clipRect(Canvas thisCanvas, RectF rect) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        return clipRect(thisCanvas, rect.left, rect.top, rect.right, rect.bottom);
     }
 
     /*package*/ static boolean clipRect(Canvas thisCanvas, Rect rect) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        return clipRect(thisCanvas, rect.left, rect.top, rect.right, rect.bottom);
     }
 
     /*package*/ static boolean clipRect(Canvas thisCanvas, float left, float top, float right,
             float bottom) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return false;
+        }
+
+        canvasDelegate.getGraphics2d().clipRect((int)left, (int)top, (int)(right-left),
+                (int)(bottom-top));
+        return true;
     }
 
     /*package*/ static boolean clipRect(Canvas thisCanvas, int left, int top, int right,
             int bottom) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return false;
+        }
+
+        canvasDelegate.getGraphics2d().clipRect(left, top, right - left, bottom - top);
+        return true;
     }
 
     /*package*/ static int save(Canvas thisCanvas) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return 0;
+        }
+
+        // get the current save count
+        int count = canvasDelegate.mGraphicsStack.size();
+
+        // create a new graphics and add it to the stack
+        Graphics2D g = (Graphics2D)canvasDelegate.getGraphics2d().create();
+        canvasDelegate.mGraphicsStack.push(g);
+
+        // return the old save count
+        return count;
+
     }
 
     /*package*/ static int save(Canvas thisCanvas, int saveFlags) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // FIXME implement save(flags)
+        return save(thisCanvas);
     }
 
     /*package*/ static void restore(Canvas thisCanvas) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return;
+        }
+
+        canvasDelegate.mGraphicsStack.pop();
     }
 
     /*package*/ static int getSaveCount(Canvas thisCanvas) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return 0;
+        }
+
+        return canvasDelegate.mGraphicsStack.size();
     }
 
     /*package*/ static void restoreToCount(Canvas thisCanvas, int saveCount) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return;
+        }
+
+        while (canvasDelegate.mGraphicsStack.size() > saveCount) {
+            canvasDelegate.mGraphicsStack.pop();
+        }
     }
 
     /*package*/ static void drawPoints(Canvas thisCanvas, float[] pts, int offset, int count,
@@ -296,8 +405,22 @@
 
     /*package*/ static boolean native_getClipBounds(int nativeCanvas,
                                                        Rect bounds) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return false;
+        }
+
+        Rectangle rect = canvasDelegate.getGraphics2d().getClipBounds();
+        if (rect != null) {
+            bounds.left = rect.x;
+            bounds.top = rect.y;
+            bounds.right = rect.x + rect.width;
+            bounds.bottom = rect.y + rect.height;
+            return true;
+        }
+        return false;
     }
 
     /*package*/ static void native_getCTM(int canvas, int matrix) {
@@ -309,14 +432,14 @@
                                                      RectF rect,
                                                      int native_edgeType) {
         // FIXME
-        throw new UnsupportedOperationException();
+        return false;
     }
 
     /*package*/ static boolean native_quickReject(int nativeCanvas,
                                                      int path,
                                                      int native_edgeType) {
         // FIXME
-        throw new UnsupportedOperationException();
+        return false;
     }
 
     /*package*/ static boolean native_quickReject(int nativeCanvas,
@@ -324,7 +447,7 @@
                                                      float right, float bottom,
                                                      int native_edgeType) {
         // FIXME
-        throw new UnsupportedOperationException();
+        return false;
     }
 
     /*package*/ static void native_drawRGB(int nativeCanvas, int r, int g,
@@ -371,8 +494,41 @@
     /*package*/ static void native_drawRect(int nativeCanvas, float left,
                                                float top, float right,
                                                float bottom, int paint) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return;
+        }
+
+        // get the delegate from the native int.
+        Paint_Delegate paintDelegate = Paint_Delegate.getDelegate(paint);
+        if (paintDelegate == null) {
+            assert false;
+            return;
+        }
+
+        if (right > left && bottom > top) {
+            // get a Graphics2D object configured with the drawing parameters.
+            Graphics2D g = canvasDelegate.getCustomGraphics(paintDelegate);
+
+            int style = paintDelegate.getStyle();
+
+            // draw
+            if (style == Paint.Style.FILL.nativeInt ||
+                    style == Paint.Style.FILL_AND_STROKE.nativeInt) {
+                g.fillRect((int)left, (int)top, (int)(right-left), (int)(bottom-top));
+            }
+
+            if (style == Paint.Style.STROKE.nativeInt ||
+                    style == Paint.Style.FILL_AND_STROKE.nativeInt) {
+                g.drawRect((int)left, (int)top, (int)(right-left), (int)(bottom-top));
+            }
+
+            // dispose Graphics2D object
+            g.dispose();
+        }
+
     }
 
     /*package*/ static void native_drawOval(int nativeCanvas, RectF oval,
@@ -423,8 +579,24 @@
                                                  int nativePaintOrZero,
                                                  int screenDensity,
                                                  int bitmapDensity) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap);
+        if (bitmapDelegate == null) {
+            assert false;
+            return;
+        }
+
+        BufferedImage image = bitmapDelegate.getImage();
+
+        if (src == null) {
+            drawBitmap(nativeCanvas, image, nativePaintOrZero,
+                    0, 0, image.getWidth(), image.getHeight(),
+                    (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom);
+        } else {
+            drawBitmap(nativeCanvas, image, nativePaintOrZero,
+                    src.left, src.top, src.width(), src.height(),
+                    (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom);
+        }
     }
 
     /*package*/ static void native_drawBitmap(int nativeCanvas, int bitmap,
@@ -432,8 +604,24 @@
                                                  int nativePaintOrZero,
                                                  int screenDensity,
                                                  int bitmapDensity) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap);
+        if (bitmapDelegate == null) {
+            assert false;
+            return;
+        }
+
+        BufferedImage image = bitmapDelegate.getImage();
+
+        if (src == null) {
+            drawBitmap(nativeCanvas, image, nativePaintOrZero,
+                    0, 0, image.getWidth(), image.getHeight(),
+                    dst.left, dst.top, dst.right, dst.bottom);
+        } else {
+            drawBitmap(nativeCanvas, image, nativePaintOrZero,
+                    src.left, src.top, src.width(), src.height(),
+                    dst.left, dst.top, dst.right, dst.bottom);
+        }
     }
 
     /*package*/ static void native_drawBitmap(int nativeCanvas, int[] colors,
@@ -471,15 +659,134 @@
     /*package*/ static void native_drawText(int nativeCanvas, char[] text,
                                                int index, int count, float x,
                                                float y, int flags, int paint) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // WARNING: the logic in this method is similar to Paint.measureText.
+        // Any change to this method should be reflected in Paint.measureText
+
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return;
+        }
+
+        // get the delegate from the native int.
+        Paint_Delegate paintDelegate = Paint_Delegate.getDelegate(paint);
+        if (paintDelegate == null) {
+            assert false;
+            return;
+        }
+
+        Graphics2D g = canvasDelegate.getGraphics2d();
+
+        g = (Graphics2D)g.create();
+        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+
+        // set the color. because this only handles RGB, the alpha channel is handled
+        // as a composite.
+        g.setColor(new Color(paintDelegate.getColor()));
+        int alpha = paintDelegate.getAlpha();
+        float falpha = alpha / 255.f;
+        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha));
+
+
+        // Paint.TextAlign indicates how the text is positioned relative to X.
+        // LEFT is the default and there's nothing to do.
+        if (paintDelegate.getTextAlign() != Paint.Align.LEFT.nativeInt) {
+            float m = paintDelegate.measureText(text, index, count);
+            if (paintDelegate.getTextAlign() == Paint.Align.CENTER.nativeInt) {
+                x -= m / 2;
+            } else if (paintDelegate.getTextAlign() == Paint.Align.RIGHT.nativeInt) {
+                x -= m;
+            }
+        }
+
+        List<FontInfo> fonts = paintDelegate.getFonts();
+        try {
+            if (fonts.size() > 0) {
+                FontInfo mainFont = fonts.get(0);
+                int i = index;
+                int lastIndex = index + count;
+                while (i < lastIndex) {
+                    // always start with the main font.
+                    int upTo = mainFont.mFont.canDisplayUpTo(text, i, lastIndex);
+                    if (upTo == -1) {
+                        // draw all the rest and exit.
+                        g.setFont(mainFont.mFont);
+                        g.drawChars(text, i, lastIndex - i, (int)x, (int)y);
+                        return;
+                    } else if (upTo > 0) {
+                        // draw what's possible
+                        g.setFont(mainFont.mFont);
+                        g.drawChars(text, i, upTo - i, (int)x, (int)y);
+
+                        // compute the width that was drawn to increase x
+                        x += mainFont.mMetrics.charsWidth(text, i, upTo - i);
+
+                        // move index to the first non displayed char.
+                        i = upTo;
+
+                        // don't call continue at this point. Since it is certain the main font
+                        // cannot display the font a index upTo (now ==i), we move on to the
+                        // fallback fonts directly.
+                    }
+
+                    // no char supported, attempt to read the next char(s) with the
+                    // fallback font. In this case we only test the first character
+                    // and then go back to test with the main font.
+                    // Special test for 2-char characters.
+                    boolean foundFont = false;
+                    for (int f = 1 ; f < fonts.size() ; f++) {
+                        FontInfo fontInfo = fonts.get(f);
+
+                        // need to check that the font can display the character. We test
+                        // differently if the char is a high surrogate.
+                        int charCount = Character.isHighSurrogate(text[i]) ? 2 : 1;
+                        upTo = fontInfo.mFont.canDisplayUpTo(text, i, i + charCount);
+                        if (upTo == -1) {
+                            // draw that char
+                            g.setFont(fontInfo.mFont);
+                            g.drawChars(text, i, charCount, (int)x, (int)y);
+
+                            // update x
+                            x += fontInfo.mMetrics.charsWidth(text, i, charCount);
+
+                            // update the index in the text, and move on
+                            i += charCount;
+                            foundFont = true;
+                            break;
+
+                        }
+                    }
+
+                    // in case no font can display the char, display it with the main font.
+                    // (it'll put a square probably)
+                    if (foundFont == false) {
+                        int charCount = Character.isHighSurrogate(text[i]) ? 2 : 1;
+
+                        g.setFont(mainFont.mFont);
+                        g.drawChars(text, i, charCount, (int)x, (int)y);
+
+                        // measure it to advance x
+                        x += mainFont.mMetrics.charsWidth(text, i, charCount);
+
+                        // and move to the next chars.
+                        i += charCount;
+                    }
+                }
+            }
+        } finally {
+            g.dispose();
+        }
     }
 
     /*package*/ static void native_drawText(int nativeCanvas, String text,
                                                int start, int end, float x,
                                                float y, int flags, int paint) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        int count = end - start;
+        char[] buffer = TemporaryBuffer.obtain(count);
+        TextUtils.getChars(text, start, end, buffer, 0);
+
+        native_drawText(nativeCanvas, buffer, 0, count, x, y, flags, paint);
     }
 
 
@@ -556,4 +863,141 @@
         mBufferedImage = image;
         mGraphicsStack.push(mBufferedImage.createGraphics());
     }
+
+    /**
+     * Creates a new {@link Graphics2D} based on the {@link Paint} parameters.
+     * <p/>The object must be disposed ({@link Graphics2D#dispose()}) after being used.
+     */
+    private Graphics2D getCustomGraphics(Paint_Delegate paint) {
+        // make new one
+        Graphics2D g = getGraphics2d();
+        g = (Graphics2D)g.create();
+
+        // configure it
+        g.setColor(new Color(paint.getColor()));
+        int alpha = paint.getAlpha();
+        float falpha = alpha / 255.f;
+
+        int style = paint.getStyle();
+        if (style == Paint.Style.STROKE.nativeInt ||
+                style == Paint.Style.FILL_AND_STROKE.nativeInt) {
+            /* FIXME
+            PathEffect e = paint.getPathEffect();
+            if (e instanceof DashPathEffect) {
+                DashPathEffect dpe = (DashPathEffect)e;
+                g.setStroke(new BasicStroke(
+                        paint.getStrokeWidth(),
+                        paint.getStrokeCap().getJavaCap(),
+                        paint.getStrokeJoin().getJavaJoin(),
+                        paint.getStrokeMiter(),
+                        dpe.getIntervals(),
+                        dpe.getPhase()));
+            } else {*/
+                g.setStroke(new BasicStroke(
+                        paint.getStrokeWidth(),
+                        paint.getJavaCap(),
+                        paint.getJavaJoin(),
+                        paint.getStrokeMiter()));
+          /*  }*/
+        }
+/*
+        Xfermode xfermode = paint.getXfermode();
+        if (xfermode instanceof PorterDuffXfermode) {
+            PorterDuff.Mode mode = ((PorterDuffXfermode)xfermode).getMode();
+
+            setModeInGraphics(mode, g, falpha);
+        } else {
+            if (mLogger != null && xfermode != null) {
+                mLogger.warning(String.format(
+                        "Xfermode '%1$s' is not supported in the Layout Editor.",
+                        xfermode.getClass().getCanonicalName()));
+            }
+            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha));
+        }
+
+        Shader shader = paint.getShader();
+        if (shader != null) {
+            java.awt.Paint shaderPaint = shader.getJavaPaint();
+            if (shaderPaint != null) {
+                g.setPaint(shaderPaint);
+            } else {
+                if (mLogger != null) {
+                    mLogger.warning(String.format(
+                            "Shader '%1$s' is not supported in the Layout Editor.",
+                            shader.getClass().getCanonicalName()));
+                }
+            }
+        }
+*/
+        return g;
+    }
+
+
+    private static void drawBitmap(
+            int nativeCanvas,
+            BufferedImage image,
+            int nativePaintOrZero,
+            int sleft, int stop, int sright, int sbottom,
+            int dleft, int dtop, int dright, int dbottom) {
+        // get the delegate from the native int.
+        Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
+        if (canvasDelegate == null) {
+            assert false;
+            return;
+        }
+
+        // get the delegate from the native int.
+        Paint_Delegate paintDelegate = null;
+        if (nativePaintOrZero > 0) {
+            paintDelegate = Paint_Delegate.getDelegate(nativePaintOrZero);
+            if (paintDelegate == null) {
+                assert false;
+                return;
+            }
+        }
+
+        drawBitmap(canvasDelegate, image, paintDelegate,
+                sleft, stop, sright, sbottom,
+                dleft, dtop, dright, dbottom);
+    }
+
+    private static void drawBitmap(
+            Canvas_Delegate canvasDelegate,
+            BufferedImage image,
+            Paint_Delegate paintDelegate,
+            int sleft, int stop, int sright, int sbottom,
+            int dleft, int dtop, int dright, int dbottom) {
+
+        Graphics2D g = canvasDelegate.getGraphics2d();
+
+        Composite c = null;
+
+        if (paintDelegate != null) {
+            if (paintDelegate.isFilterBitmap()) {
+                g = (Graphics2D)g.create();
+                g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+                        RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+            }
+
+            if (paintDelegate.getAlpha() != 0xFF) {
+                c = g.getComposite();
+                g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
+                        paintDelegate.getAlpha()/255.f));
+            }
+        }
+
+        g.drawImage(image, dleft, dtop, dright, dbottom,
+                sleft, stop, sright, sbottom, null);
+
+        if (paintDelegate != null) {
+            if (paintDelegate.isFilterBitmap()) {
+                g.dispose();
+            }
+            if (c != null) {
+                g.setComposite(c);
+            }
+        }
+    }
+
 }
+
diff --git a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
index cc4a80c..713f7840 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
@@ -689,13 +689,17 @@
     // ---- Private helper methods ----
 
     private static AffineTransform getAffineTransform(Matrix_Delegate d) {
+        return getAffineTransform(d.mValues);
+    }
+
+    /*package*/ static AffineTransform getAffineTransform(float[] matrix) {
         // the AffineTransform constructor takes the value in a different order
         // for a matrix [ 0 1 2 ]
         //              [ 3 4 5 ]
         // the order is 0, 3, 1, 4, 2, 5...
         return new AffineTransform(
-                d.mValues[0], d.mValues[3], d.mValues[1],
-                d.mValues[4], d.mValues[2], d.mValues[5]);
+                matrix[0], matrix[3], matrix[1],
+                matrix[4], matrix[2], matrix[5]);
     }
 
 
@@ -862,7 +866,7 @@
      * <p/>This in effect does dest = a*b
      * dest cannot be the same as a or b.
      */
-    private static void multiply(float dest[], float[] a, float[] b) {
+     /*package*/ static void multiply(float dest[], float[] a, float[] b) {
         // first row
         dest[0] = b[0] * a[0] + b[1] * a[3] + b[2] * a[6];
         dest[1] = b[0] * a[1] + b[1] * a[4] + b[2] * a[7];
@@ -885,11 +889,11 @@
      * @param dy
      * @return
      */
-    private static float[] getTranslate(float dx, float dy) {
+    /*package*/ static float[] getTranslate(float dx, float dy) {
         return setTranslate(new float[9], dx, dy);
     }
 
-    private static float[] setTranslate(float[] dest, float dx, float dy) {
+    /*package*/ static float[] setTranslate(float[] dest, float dx, float dy) {
         dest[0] = 1;
         dest[1] = 0;
         dest[2] = dx;
@@ -902,7 +906,7 @@
         return dest;
     }
 
-    private static float[] getScale(float sx, float sy) {
+    /*package*/ static float[] getScale(float sx, float sy) {
         return new float[] { sx, 0, 0, 0, sy, 0, 0, 0, 1 };
     }
 
@@ -913,7 +917,7 @@
      * @param px
      * @param py
      */
-    private static float[] getScale(float sx, float sy, float px, float py) {
+    /*package*/ static float[] getScale(float sx, float sy, float px, float py) {
         float[] tmp = new float[9];
         float[] tmp2 = new float[9];
 
@@ -932,7 +936,7 @@
     }
 
 
-    private static float[] getRotate(float degrees) {
+    /*package*/ static float[] getRotate(float degrees) {
         double rad = Math.toRadians(degrees);
         float sin = (float)Math.sin(rad);
         float cos = (float)Math.cos(rad);
@@ -940,11 +944,11 @@
         return getRotate(sin, cos);
     }
 
-    private static float[] getRotate(float sin, float cos) {
+    /*package*/ static float[] getRotate(float sin, float cos) {
         return setRotate(new float[9], sin, cos);
     }
 
-    private static float[] setRotate(float[] dest, float degrees) {
+    /*package*/ static float[] setRotate(float[] dest, float degrees) {
         double rad = Math.toRadians(degrees);
         float sin = (float)Math.sin(rad);
         float cos = (float)Math.cos(rad);
@@ -952,7 +956,7 @@
         return setRotate(dest, sin, cos);
     }
 
-    private static float[] setRotate(float[] dest, float sin, float cos) {
+    /*package*/ static float[] setRotate(float[] dest, float sin, float cos) {
         dest[0] = cos;
         dest[1] = -sin;
         dest[2] = 0;
@@ -965,7 +969,7 @@
         return dest;
     }
 
-    private static float[] getRotate(float degrees, float px, float py) {
+    /*package*/ static float[] getRotate(float degrees, float px, float py) {
         float[] tmp = new float[9];
         float[] tmp2 = new float[9];
 
@@ -986,11 +990,11 @@
         return tmp;
     }
 
-    private static float[] getSkew(float kx, float ky) {
+    /*package*/ static float[] getSkew(float kx, float ky) {
         return new float[] { 1, kx, 0, ky, 1, 0, 0, 0, 1 };
     }
 
-    private static float[] getSkew(float kx, float ky, float px, float py) {
+    /*package*/ static float[] getSkew(float kx, float ky, float px, float py) {
         float[] tmp = new float[9];
         float[] tmp2 = new float[9];
 
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
index e8079ed..f2602b5 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
@@ -20,7 +20,9 @@
 
 import android.graphics.Paint.FontMetrics;
 import android.graphics.Paint.FontMetricsInt;
+import android.text.TextUtils;
 
+import java.awt.BasicStroke;
 import java.awt.Font;
 import java.awt.Toolkit;
 import java.awt.font.FontRenderContext;
@@ -47,7 +49,7 @@
     /**
      * Class associating a {@link Font} and it's {@link java.awt.FontMetrics}.
      */
-    public static final class FontInfo {
+    /*package*/ static final class FontInfo {
         Font mFont;
         java.awt.FontMetrics mMetrics;
     }
@@ -67,7 +69,7 @@
     private int mStyle;
     private int mCap;
     private int mJoin;
-    private int mAlign;
+    private int mTextAlign;
     private int mTypeface;
     private float mStrokeWidth;
     private float mStrokeMiter;
@@ -78,6 +80,10 @@
 
     // ---- Public Helper methods ----
 
+    public static Paint_Delegate getDelegate(int native_paint) {
+        return sManager.getDelegate(native_paint);
+    }
+
     /**
      * Returns the list of {@link Font} objects. The first item is the main font, the rest
      * are fall backs for characters not present in the main font.
@@ -86,6 +92,57 @@
         return mFonts;
     }
 
+    public boolean isFilterBitmap() {
+        return (mFlags & Paint.FILTER_BITMAP_FLAG) != 0;
+    }
+
+    public int getStyle() {
+        return mStyle;
+    }
+
+    public int getColor() {
+        return mColor;
+    }
+
+    public int getAlpha() {
+        return mColor >>> 24;
+    }
+
+    public int getTextAlign() {
+        return mTextAlign;
+    }
+
+    public float getStrokeWidth() {
+        return mStrokeWidth;
+    }
+
+    public float getStrokeMiter() {
+        return mStrokeMiter;
+    }
+
+    public int getJavaCap() {
+        switch (Paint.sCapArray[mCap]) {
+            case BUTT:
+                return BasicStroke.CAP_BUTT;
+            case ROUND:
+                return BasicStroke.CAP_ROUND;
+            default:
+            case SQUARE:
+                return BasicStroke.CAP_SQUARE;
+        }
+    }
+
+    public int getJavaJoin() {
+        switch (Paint.sJoinArray[mJoin]) {
+            default:
+            case MITER:
+                return BasicStroke.JOIN_MITER;
+            case ROUND:
+                return BasicStroke.JOIN_ROUND;
+            case BEVEL:
+                return BasicStroke.JOIN_BEVEL;
+        }
+    }
 
     // ---- native methods ----
 
@@ -112,8 +169,7 @@
     }
 
     /*package*/ static void setFilterBitmap(Paint thisPaint, boolean filter) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        setFlag(thisPaint, Paint.FILTER_BITMAP_FLAG, filter);
     }
 
     /*package*/ static void setAntiAlias(Paint thisPaint, boolean aa) {
@@ -174,7 +230,7 @@
             return 0;
         }
 
-        return delegate.mColor >>> 24;
+        return delegate.getAlpha();
     }
 
     /*package*/ static void setAlpha(Paint thisPaint, int a) {
@@ -315,13 +371,53 @@
     }
 
     /*package*/ static float getFontMetrics(Paint thisPaint, FontMetrics metrics) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate
+        Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint);
+        if (delegate == null) {
+            assert false;
+            return 0;
+        }
+
+        if (delegate.mFonts.size() > 0) {
+            java.awt.FontMetrics javaMetrics = delegate.mFonts.get(0).mMetrics;
+            if (metrics != null) {
+                // Android expects negative ascent so we invert the value from Java.
+                metrics.top = - javaMetrics.getMaxAscent();
+                metrics.ascent = - javaMetrics.getAscent();
+                metrics.descent = javaMetrics.getDescent();
+                metrics.bottom = javaMetrics.getMaxDescent();
+                metrics.leading = javaMetrics.getLeading();
+            }
+
+            return javaMetrics.getHeight();
+        }
+
+        return 0;
     }
 
     /*package*/ static int getFontMetricsInt(Paint thisPaint, FontMetricsInt fmi) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate
+        Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint);
+        if (delegate == null) {
+            assert false;
+            return 0;
+        }
+
+        if (delegate.mFonts.size() > 0) {
+            java.awt.FontMetrics javaMetrics = delegate.mFonts.get(0).mMetrics;
+            if (fmi != null) {
+                // Android expects negative ascent so we invert the value from Java.
+                fmi.top = - javaMetrics.getMaxAscent();
+                fmi.ascent = - javaMetrics.getAscent();
+                fmi.descent = javaMetrics.getDescent();
+                fmi.bottom = javaMetrics.getMaxDescent();
+                fmi.leading = javaMetrics.getLeading();
+            }
+
+            return javaMetrics.getHeight();
+        }
+
+        return 0;
     }
 
     /*package*/ static float native_measureText(Paint thisPaint, char[] text, int index,
@@ -336,56 +432,7 @@
             return 0;
         }
 
-        if (delegate.mFonts.size() > 0) {
-            FontInfo mainFont = delegate.mFonts.get(0);
-            int i = index;
-            int lastIndex = index + count;
-            float total = 0f;
-            while (i < lastIndex) {
-                // always start with the main font.
-                int upTo = mainFont.mFont.canDisplayUpTo(text, i, lastIndex);
-                if (upTo == -1) {
-                    // shortcut to exit
-                    return total + mainFont.mMetrics.charsWidth(text, i, lastIndex - i);
-                } else if (upTo > 0) {
-                    total += mainFont.mMetrics.charsWidth(text, i, upTo - i);
-                    i = upTo;
-                    // don't call continue at this point. Since it is certain the main font
-                    // cannot display the font a index upTo (now ==i), we move on to the
-                    // fallback fonts directly.
-                }
-
-                // no char supported, attempt to read the next char(s) with the
-                // fallback font. In this case we only test the first character
-                // and then go back to test with the main font.
-                // Special test for 2-char characters.
-                boolean foundFont = false;
-                for (int f = 1 ; f < delegate.mFonts.size() ; f++) {
-                    FontInfo fontInfo = delegate.mFonts.get(f);
-
-                    // need to check that the font can display the character. We test
-                    // differently if the char is a high surrogate.
-                    int charCount = Character.isHighSurrogate(text[i]) ? 2 : 1;
-                    upTo = fontInfo.mFont.canDisplayUpTo(text, i, i + charCount);
-                    if (upTo == -1) {
-                        total += fontInfo.mMetrics.charsWidth(text, i, charCount);
-                        i += charCount;
-                        foundFont = true;
-                        break;
-
-                    }
-                }
-
-                // in case no font can display the char, measure it with the main font.
-                if (foundFont == false) {
-                    int size = Character.isHighSurrogate(text[i]) ? 2 : 1;
-                    total += mainFont.mMetrics.charsWidth(text, i, size);
-                    i += size;
-                }
-            }
-        }
-
-        return 0;
+        return delegate.measureText(text, index, count);
     }
 
     /*package*/ static float native_measureText(Paint thisPaint, String text, int start, int end) {
@@ -576,7 +623,7 @@
             return 0;
         }
 
-        return delegate.mAlign;
+        return delegate.mTextAlign;
     }
 
     /*package*/ static void native_setTextAlign(int native_object, int align) {
@@ -587,7 +634,7 @@
             return;
         }
 
-        delegate.mAlign = align;
+        delegate.mTextAlign = align;
     }
 
     /*package*/ static float native_getFontMetrics(int native_paint, FontMetrics metrics) {
@@ -610,15 +657,58 @@
     /*package*/ static float native_getTextRunAdvances(int native_object,
             char[] text, int index, int count, int contextIndex, int contextCount,
             int flags, float[] advances, int advancesIndex) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // get the delegate from the native int.
+        Paint_Delegate delegate = sManager.getDelegate(native_object);
+        if (delegate == null) {
+            assert false;
+            return 0.f;
+        }
+
+        if (delegate.mFonts.size() > 0) {
+            // FIXME: handle multi-char characters.
+            // see measureText.
+            float totalAdvance = 0;
+            for (int i = 0; i < count; i++) {
+                char c = text[i + index];
+                boolean found = false;
+                for (FontInfo info : delegate.mFonts) {
+                    if (info.mFont.canDisplay(c)) {
+                        float adv = info.mMetrics.charWidth(c);
+                        totalAdvance += adv;
+                        if (advances != null) {
+                            advances[i] = adv;
+                        }
+
+                        found = true;
+                        break;
+                    }
+                }
+
+                if (found == false) {
+                    // no advance for this char.
+                    if (advances != null) {
+                        advances[i] = 0.f;
+                    }
+                }
+            }
+
+            return totalAdvance;
+        }
+
+        return 0;
+
     }
 
     /*package*/ static float native_getTextRunAdvances(int native_object,
             String text, int start, int end, int contextStart, int contextEnd,
             int flags, float[] advances, int advancesIndex) {
-        // FIXME
-        throw new UnsupportedOperationException();
+        // FIXME: support contextStart, contextEnd and direction flag
+        int count = end - start;
+        char[] buffer = TemporaryBuffer.obtain(count);
+        TextUtils.getChars(text, start, end, buffer, 0);
+
+        return native_getTextRunAdvances(native_object, buffer, 0, count, contextStart,
+                contextEnd - contextStart, flags, advances, advancesIndex);
     }
 
     /*package*/ static int native_getTextRunCursor(Paint thisPaint, int native_object, char[] text,
@@ -681,7 +771,7 @@
         mStyle = paint.mStyle;
         mCap = paint.mCap;
         mJoin = paint.mJoin;
-        mAlign = paint.mAlign;
+        mTextAlign = paint.mTextAlign;
         mTypeface = paint.mTypeface;
         mStrokeWidth = paint.mStrokeWidth;
         mStrokeMiter = paint.mStrokeMiter;
@@ -696,7 +786,7 @@
         mStyle = 0;
         mCap = 0;
         mJoin = 0;
-        mAlign = 0;
+        mTextAlign = 0;
         mTypeface = 0;
         mStrokeWidth = 1.f;
         mStrokeMiter = 2.f;
@@ -733,6 +823,61 @@
         }
     }
 
+    /*package*/ float measureText(char[] text, int index, int count) {
+        if (mFonts.size() > 0) {
+            FontInfo mainFont = mFonts.get(0);
+            int i = index;
+            int lastIndex = index + count;
+            float total = 0f;
+            while (i < lastIndex) {
+                // always start with the main font.
+                int upTo = mainFont.mFont.canDisplayUpTo(text, i, lastIndex);
+                if (upTo == -1) {
+                    // shortcut to exit
+                    return total + mainFont.mMetrics.charsWidth(text, i, lastIndex - i);
+                } else if (upTo > 0) {
+                    total += mainFont.mMetrics.charsWidth(text, i, upTo - i);
+                    i = upTo;
+                    // don't call continue at this point. Since it is certain the main font
+                    // cannot display the font a index upTo (now ==i), we move on to the
+                    // fallback fonts directly.
+                }
+
+                // no char supported, attempt to read the next char(s) with the
+                // fallback font. In this case we only test the first character
+                // and then go back to test with the main font.
+                // Special test for 2-char characters.
+                boolean foundFont = false;
+                for (int f = 1 ; f < mFonts.size() ; f++) {
+                    FontInfo fontInfo = mFonts.get(f);
+
+                    // need to check that the font can display the character. We test
+                    // differently if the char is a high surrogate.
+                    int charCount = Character.isHighSurrogate(text[i]) ? 2 : 1;
+                    upTo = fontInfo.mFont.canDisplayUpTo(text, i, i + charCount);
+                    if (upTo == -1) {
+                        total += fontInfo.mMetrics.charsWidth(text, i, charCount);
+                        i += charCount;
+                        foundFont = true;
+                        break;
+
+                    }
+                }
+
+                // in case no font can display the char, measure it with the main font.
+                if (foundFont == false) {
+                    int size = Character.isHighSurrogate(text[i]) ? 2 : 1;
+                    total += mainFont.mMetrics.charsWidth(text, i, size);
+                    i += size;
+                }
+            }
+        }
+
+        return 0;
+
+    }
+
+
     private static void setFlag(Paint thisPaint, int flagMask, boolean flagValue) {
         // get the delegate from the native int.
         Paint_Delegate delegate = sManager.getDelegate(thisPaint.mNativePaint);