Merge "Fix bug 3425610 Reduce lock / unlock sound level" into honeycomb
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index ac3df79..13ea13f 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -500,7 +500,7 @@
                         choosehtv, fm, hasTabOrEmoji,
                         needMultiply, paraStart, chdirs, dir, easy,
                         paraEnd == bufend, includepad, trackpad,
-                        chs, widths, here - paraStart,
+                        chs, widths, paraStart,
                         ellipsize, ellipsizedWidth, w, paint);
             }
 
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index 2aa94dc..3bab29f 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -190,6 +190,7 @@
         mDialog.setOnDismissListener(new OnDismissListener() {
             public void onDismiss(DialogInterface dialog) {
                 mActiveStreamType = -1;
+                mAudioManager.forceVolumeControlStream(mActiveStreamType);
             }
         });
         // Change some window properties
@@ -483,6 +484,7 @@
         }
 
         if (!mDialog.isShowing()) {
+            mAudioManager.forceVolumeControlStream(streamType);
             mDialog.setContentView(mView);
             // Showing dialog - use collapsed state
             collapse();
diff --git a/core/jni/android/graphics/Path.cpp b/core/jni/android/graphics/Path.cpp
index 90c4dd4..eb9e004 100644
--- a/core/jni/android/graphics/Path.cpp
+++ b/core/jni/android/graphics/Path.cpp
@@ -36,7 +36,8 @@
     static void finalizer(JNIEnv* env, jobject clazz, SkPath* obj) {
 #ifdef USE_OPENGL_RENDERER
         if (android::uirenderer::Caches::hasInstance()) {
-            android::uirenderer::Caches::getInstance().pathCache.removeDeferred(obj);
+            android::uirenderer::Caches::getInstance().resourceCache.destructor(obj);
+            return;
         }
 #endif
         delete obj;
diff --git a/data/sounds/effects/ogg/KeypressSpacebar.ogg b/data/sounds/effects/ogg/KeypressSpacebar.ogg
index 1776762..0d0fbf1 100644
--- a/data/sounds/effects/ogg/KeypressSpacebar.ogg
+++ b/data/sounds/effects/ogg/KeypressSpacebar.ogg
Binary files differ
diff --git a/data/sounds/effects/ogg/KeypressStandard.ogg b/data/sounds/effects/ogg/KeypressStandard.ogg
index a261975..5878135 100644
--- a/data/sounds/effects/ogg/KeypressStandard.ogg
+++ b/data/sounds/effects/ogg/KeypressStandard.ogg
Binary files differ
diff --git a/docs/html/guide/publishing/licensing.jd b/docs/html/guide/publishing/licensing.jd
index e099413..5551384 100644
--- a/docs/html/guide/publishing/licensing.jd
+++ b/docs/html/guide/publishing/licensing.jd
@@ -2123,7 +2123,7 @@
 <tr>
 <td>LICENSED</td>
 <td>The application is licensed to the user. The user has purchased the
-application or the application is free.</td>
+application or the application only exists as a draft.</td>
 <td>Yes</td>
 <td><code>VT</code>,&nbsp;<code>GT</code>, <code>GR</code></td>
 <td><em>Allow access according to Policy constraints.</em></td>
@@ -2201,6 +2201,17 @@
 
 </table>
 
+<p class="note"><strong>Note:</strong> As documented in <a href="#test-env">
+Setting Up The Testing Environment</a>, the response code can be manually
+overridden for the application developer and any registered test users via the
+Android Market publisher site.
+<br/><br/>
+Additionally, as noted above, applications that are in draft mode (in other
+words, applicaitons that have been uploaded but have <em>never</em> been
+published) will return LICENSED for all users, even if not listed as a test
+user. Since the application has never been offered for download, it is assumed
+that any users running it must have obtained it from an authorized channel for
+testing purposes.</p>
 
 <h2 id="extras">Server Response Extras</h2>
 
diff --git a/docs/html/guide/topics/fundamentals/index.jd b/docs/html/guide/topics/fundamentals/index.jd
index de2e312..f427a92 100644
--- a/docs/html/guide/topics/fundamentals/index.jd
+++ b/docs/html/guide/topics/fundamentals/index.jd
@@ -180,9 +180,7 @@
 
 <p>A broadcast receiver is implemented as a subclass of {@link android.content.BroadcastReceiver}
 and each broadcast is delivered as an {@link android.content.Intent} object. For more information,
-see the <a
-href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
-developer guide.</p>
+see the {@link android.content.BroadcastReceiver} class.</p>
 </dd>
 
 </dl>
@@ -220,35 +218,56 @@
 as the messengers that request an action from other components), whether the component belongs
 to your application or another.</p>
 
-<p>An intent is defined by an {@link android.content.Intent} object, which defines a message to
+<p>An intent is created with an {@link android.content.Intent} object, which defines a message to
 activate either a specific component or a specific <em>type</em> of component&mdash;an intent
 can be either explicit or implicit, respectively.</p>
 
 <p>For activities and services, an intent defines the action to perform (for example, to "view" or
 "send" something) and may specify the URI of the data to act on (among other things that the
 component being started might need to know). For example, an intent might convey a request for an
-activity to present an image to the user or to open a web page. In some cases, you can start a
-component in order to receive a result, in which case, the component that is started also returns
-the result in an {@link android.content.Intent} object (for example, you can issue an intent to let
+activity to show an image or to open a web page. In some cases, you can start an
+activity to receive a result, in which case, the activity also returns
+the result in an {@link android.content.Intent} (for example, you can issue an intent to let
 the user pick a personal contact and have it returned to you&mdash;the return intent includes a
-URI pointing to the chosen contact). For broadcast receivers, the intent simply defines the
+URI pointing to the chosen contact).</p>
+
+<p>For broadcast receivers, the intent simply defines the
 announcement being broadcast (for example, a broadcast to indicate the device battery is low
 includes only a known action string that indicates "battery is low").</p>
 
-<p>The remaining type of component, content provider, is not activated by intents. Rather, it is
+<p>The other component type, content provider, is not activated by intents. Rather, it is
 activated when targeted by a request from a {@link android.content.ContentResolver}. The content
 resolver handles all direct transactions with the content provider so that the component that's
 performing transactions with the provider doesn't need to and instead calls methods on the {@link
 android.content.ContentResolver} object. This leaves a layer of abstraction between the content
 provider and the component requesting information (for security).</p>
 
+<p>There are separate methods for activiting each type of component:</p>
+<ul>
+  <li>You can start an activity (or give it something new to do) by
+passing an {@link android.content.Intent} to {@link android.content.Context#startActivity
+startActivity()} or {@link android.app.Activity#startActivityForResult startActivityForResult()}
+(when you want the activity to return a result).</li>
+  <li>You can start a service (or give new instructions to an ongoing service) by
+passing an {@link android.content.Intent} to {@link android.content.Context#startService
+startService()}. Or you can bind to the service by passing an {@link android.content.Intent} to
+{@link android.content.Context#bindService bindService()}.</li>
+  <li>You can initiate a broadcast by passing an {@link android.content.Intent} to methods like
+{@link android.content.Context#sendBroadcast(Intent) sendBroadcast()}, {@link
+android.content.Context#sendOrderedBroadcast(Intent, String) sendOrderedBroadcast()}, or {@link
+android.content.Context#sendStickyBroadcast sendStickyBroadcast()}.</li>
+  <li>You can perform a query to a content provider by calling {@link
+android.content.ContentProvider#query query()} on a {@link android.content.ContentResolver}.</li>
+</ul>
+
 <p>For more information about using intents, see the <a
 href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and
 Intent Filters</a> document. More information about activating specific components is also provided
-in the <a href="{@docRoot}guide/topics/fundamentals/activities.html">Activities</a>, <a
-href="{@docRoot}guide/topics/fundamentals/services.html">Services</a>, and <a
-href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> developer
-guides.</p>
+in the following documents: <a
+href="{@docRoot}guide/topics/fundamentals/activities.html">Activities</a>, <a
+href="{@docRoot}guide/topics/fundamentals/services.html">Services</a>, {@link
+android.content.BroadcastReceiver} and <a
+href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a>.</p>
 
 
 <h2 id="Manifest">The Manifest File</h2>
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 3c4b565..d6cc8ce 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -77,7 +77,8 @@
 
 SurfaceTexture::SurfaceTexture(GLuint tex) :
     mBufferCount(MIN_BUFFER_SLOTS), mCurrentTexture(INVALID_BUFFER_SLOT),
-    mLastQueued(INVALID_BUFFER_SLOT), mTexName(tex) {
+    mCurrentTransform(0), mLastQueued(INVALID_BUFFER_SLOT),
+    mLastQueuedTransform(0), mNextTransform(0), mTexName(tex) {
     LOGV("SurfaceTexture::SurfaceTexture");
     for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
         mSlots[i].mEglImage = EGL_NO_IMAGE_KHR;
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 2df52ae..d5d2ba0 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -95,6 +95,10 @@
         delete mPaths.itemAt(i);
     }
     mPaths.clear();
+    for (size_t i = 0; i < mOriginalPaths.size(); i++) {
+        caches.resourceCache.decrementRefcount(mOriginalPaths.itemAt(i));
+    }
+    mOriginalPaths.clear();
 
     for (size_t i = 0; i < mMatrices.size(); i++) {
         delete mMatrices.itemAt(i);
@@ -146,6 +150,13 @@
         mPaths.add(paths.itemAt(i));
     }
 
+    const Vector<SkPath*> &originalPaths = recorder.getOriginalPaths();
+    for (size_t i = 0; i < originalPaths.size(); i++) {
+        SkPath* path = originalPaths.itemAt(i);
+        mOriginalPaths.add(path);
+        caches.resourceCache.incrementRefcount(path);
+    }
+
     const Vector<SkMatrix*> &matrices = recorder.getMatrices();
     for (size_t i = 0; i < matrices.size(); i++) {
         mMatrices.add(matrices.itemAt(i));
@@ -519,6 +530,12 @@
     }
     mBitmapResources.clear();
 
+    for (size_t i = 0; i < mOriginalPaths.size(); i++) {
+        SkPath* resource = mOriginalPaths.itemAt(i);
+        caches.resourceCache.decrementRefcount(resource);
+    }
+    mOriginalPaths.clear();
+
     for (size_t i = 0; i < mShaders.size(); i++) {
        caches.resourceCache.decrementRefcount(mShaders.itemAt(i));
     }
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 2d0e30a..f39f37f 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -190,6 +190,7 @@
 
     Vector<SkPaint*> mPaints;
     Vector<SkPath*> mPaths;
+    Vector<SkPath*> mOriginalPaths;
     Vector<SkMatrix*> mMatrices;
     Vector<SkiaShader*> mShaders;
 
@@ -293,6 +294,10 @@
         return mPaths;
     }
 
+    const Vector<SkPath*>& getOriginalPaths() const {
+        return mOriginalPaths;
+    }
+
     const Vector<SkMatrix*>& getMatrices() const {
         return mMatrices;
     }
@@ -371,6 +376,9 @@
         if (pathCopy == NULL || pathCopy->getGenerationID() != path->getGenerationID()) {
             if (pathCopy == NULL) {
                 pathCopy = path;
+                mOriginalPaths.add(path);
+                Caches& caches = Caches::getInstance();
+                caches.resourceCache.incrementRefcount(path);
             } else {
                 pathCopy = new SkPath(*path);
                 mPaths.add(pathCopy);
@@ -452,6 +460,7 @@
     Vector<SkPaint*> mPaints;
     DefaultKeyedVector<SkPaint*, SkPaint*> mPaintMap;
 
+    Vector<SkPath*> mOriginalPaths;
     Vector<SkPath*> mPaths;
     DefaultKeyedVector<SkPath*, SkPath*> mPathMap;
 
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 90d6ea1..8ee7ec3 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1217,17 +1217,18 @@
 #if RENDER_LAYERS_AS_REGIONS
         // Mark the current layer dirty where we are going to draw the patch
         if (hasLayer() && mesh->hasEmptyQuads) {
+            const float offsetX = left + mSnapshot->transform->getTranslateX();
+            const float offsetY = top + mSnapshot->transform->getTranslateY();
             const size_t count = mesh->quads.size();
             for (size_t i = 0; i < count; i++) {
                 const Rect& bounds = mesh->quads.itemAt(i);
                 if (pureTranslate) {
-                    const float x = (int) floorf(bounds.left + 0.5f);
-                    const float y = (int) floorf(bounds.top + 0.5f);
-                    dirtyLayer(x, y, x + bounds.getWidth(), y + bounds.getHeight(),
-                            *mSnapshot->transform);
+                    const float x = (int) floorf(bounds.left + offsetX + 0.5f);
+                    const float y = (int) floorf(bounds.top + offsetY + 0.5f);
+                    dirtyLayer(x, y, x + bounds.getWidth(), y + bounds.getHeight());
                 } else {
-                    dirtyLayer(bounds.left, bounds.top, bounds.right, bounds.bottom,
-                            *mSnapshot->transform);
+                    dirtyLayer(left + bounds.left, top + bounds.top,
+                            left + bounds.right, top + bounds.bottom, *mSnapshot->transform);
                 }
             }
         }
diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index 70d117a..87fdfb5 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -65,6 +65,10 @@
     incrementRefcount((void*)bitmapResource, kBitmap);
 }
 
+void ResourceCache::incrementRefcount(SkPath* pathResource) {
+    incrementRefcount((void*)pathResource, kPath);
+}
+
 void ResourceCache::incrementRefcount(SkiaShader* shaderResource) {
     shaderResource->getSkShader()->safeRef();
     incrementRefcount((void*) shaderResource, kShader);
@@ -94,6 +98,10 @@
     decrementRefcount((void*) bitmapResource);
 }
 
+void ResourceCache::decrementRefcount(SkPath* pathResource) {
+    decrementRefcount((void*) pathResource);
+}
+
 void ResourceCache::decrementRefcount(SkiaShader* shaderResource) {
     shaderResource->getSkShader()->safeUnref();
     decrementRefcount((void*) shaderResource);
@@ -122,6 +130,24 @@
     }
 }
 
+void ResourceCache::destructor(SkPath* resource) {
+    Mutex::Autolock _l(mLock);
+    ResourceReference* ref = mCache->indexOfKey(resource) >= 0 ? mCache->valueFor(resource) : NULL;
+    if (ref == NULL) {
+        // If we're not tracking this resource, just delete it
+        if (Caches::hasInstance()) {
+            Caches::getInstance().pathCache.removeDeferred(resource);
+        }
+        delete resource;
+        return;
+    }
+    ref->destroyed = true;
+    if (ref->refCount == 0) {
+        deleteResourceReference(resource, ref);
+        return;
+    }
+}
+
 void ResourceCache::destructor(SkBitmap* resource) {
     Mutex::Autolock _l(mLock);
     ResourceReference* ref = mCache->indexOfKey(resource) >= 0 ? mCache->valueFor(resource) : NULL;
@@ -192,6 +218,15 @@
                 delete bitmap;
             }
             break;
+            case kPath:
+            {
+                SkPath* path = (SkPath*)resource;
+                if (Caches::hasInstance()) {
+                    Caches::getInstance().pathCache.removeDeferred(path);
+                }
+                delete path;
+            }
+            break;
             case kShader:
             {
                 SkiaShader* shader = (SkiaShader*)resource;
diff --git a/libs/hwui/ResourceCache.h b/libs/hwui/ResourceCache.h
index 1bb4390..2a38910 100644
--- a/libs/hwui/ResourceCache.h
+++ b/libs/hwui/ResourceCache.h
@@ -32,6 +32,7 @@
     kBitmap,
     kShader,
     kColorFilter,
+    kPath,
 };
 
 class ResourceReference {
@@ -53,15 +54,18 @@
 public:
     ResourceCache();
     ~ResourceCache();
+    void incrementRefcount(SkPath* resource);
     void incrementRefcount(SkBitmap* resource);
     void incrementRefcount(SkiaShader* resource);
     void incrementRefcount(SkiaColorFilter* resource);
     void incrementRefcount(const void* resource, ResourceType resourceType);
     void decrementRefcount(void* resource);
     void decrementRefcount(SkBitmap* resource);
+    void decrementRefcount(SkPath* resource);
     void decrementRefcount(SkiaShader* resource);
     void decrementRefcount(SkiaColorFilter* resource);
     void recycle(SkBitmap* resource);
+    void destructor(SkPath* resource);
     void destructor(SkBitmap* resource);
     void destructor(SkiaShader* resource);
     void destructor(SkiaColorFilter* resource);
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp
index 8a85f6e..80da8ae 100644
--- a/libs/rs/rsScriptC_Lib.cpp
+++ b/libs/rs/rsScriptC_Lib.cpp
@@ -856,6 +856,8 @@
     { "__modsi3", (void *)&SC_modsi3, true },
     { "__udivsi3", (void *)&SC_udivsi3, true },
     { "__umodsi3", (void *)&SC_umodsi3, true },
+    { "memset", (void *)&memset, true },
+    { "memcpy", (void *)&memcpy, true },
 
     // allocation
     { "_Z19rsAllocationGetDimX13rs_allocation", (void *)&SC_allocGetDimX, true },
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 051a0fc..5a59ef6 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -48,7 +48,7 @@
     private final Context mContext;
     private final Handler mHandler;
     private long mVolumeKeyUpTime;
-
+    private int  mVolumeControlStream = -1;
     private static String TAG = "AudioManager";
     private static boolean DEBUG = false;
     private static boolean localLOGV = DEBUG || android.util.Config.LOGV;
@@ -263,6 +263,13 @@
     public static final int FLAG_VIBRATE = 1 << 4;
 
     /**
+     * forces use of specified stream
+     * @hide
+     */
+    public static final int FLAG_FORCE_STREAM = 1 << 5;
+
+
+    /**
      * Ringer mode that will be silent and will not vibrate. (This overrides the
      * vibrate setting.)
      *
@@ -392,12 +399,17 @@
                  * Adjust the volume in on key down since it is more
                  * responsive to the user.
                  */
+                int flags = FLAG_SHOW_UI | FLAG_VIBRATE;
+                if (mVolumeControlStream != -1) {
+                    stream = mVolumeControlStream;
+                    flags |= FLAG_FORCE_STREAM;
+                }
                 adjustSuggestedStreamVolume(
                         keyCode == KeyEvent.KEYCODE_VOLUME_UP
                                 ? ADJUST_RAISE
                                 : ADJUST_LOWER,
                         stream,
-                        FLAG_SHOW_UI | FLAG_VIBRATE);
+                        flags);
                 break;
             case KeyEvent.KEYCODE_VOLUME_MUTE:
                 // TODO: Actually handle MUTE.
@@ -416,10 +428,15 @@
                  * 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.
                  */
+                int flags = FLAG_PLAY_SOUND;
+                if (mVolumeControlStream != -1) {
+                    stream = mVolumeControlStream;
+                    flags |= FLAG_FORCE_STREAM;
+                }
                 adjustSuggestedStreamVolume(
                         ADJUST_SAME,
                         stream,
-                        FLAG_PLAY_SOUND);
+                        flags);
 
                 mVolumeKeyUpTime = SystemClock.uptimeMillis();
                 break;
@@ -683,6 +700,17 @@
     }
 
     /**
+     * forces the stream controlled by hard volume keys
+     * specifying streamType == -1 releases control to the
+     * logic.
+     *
+     * @hide
+     */
+    public void forceVolumeControlStream(int streamType) {
+        mVolumeControlStream = streamType;
+    }
+
+    /**
      * Returns whether a particular type should vibrate according to user
      * settings and the current ringer mode.
      * <p>
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index e18220a..ba6f548 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -417,6 +417,9 @@
                  (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED)|
                  (1 << AudioSystem.STREAM_MUSIC)));
 
+        if (!mVoiceCapable) {
+            mRingerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC);
+        }
         mMuteAffectedStreams = System.getInt(cr,
                 System.MUTE_STREAMS_AFFECTED,
                 ((1 << AudioSystem.STREAM_MUSIC)|(1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_SYSTEM)));
@@ -461,7 +464,12 @@
     /** @see AudioManager#adjustVolume(int, int, int) */
     public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) {
 
-        int streamType = getActiveStreamType(suggestedStreamType);
+        int streamType;
+        if ((flags & AudioManager.FLAG_FORCE_STREAM) != 0) {
+            streamType = suggestedStreamType;
+        } else {
+            streamType = getActiveStreamType(suggestedStreamType);
+        }
 
         // Don't play sound on other streams
         if (streamType != AudioSystem.STREAM_RING && (flags & AudioManager.FLAG_PLAY_SOUND) != 0) {
@@ -2025,6 +2033,10 @@
                 int ringerModeAffectedStreams = Settings.System.getInt(mContentResolver,
                         Settings.System.MODE_RINGER_STREAMS_AFFECTED,
                         0);
+                if (!mVoiceCapable) {
+                    ringerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC);
+                }
+
                 if (ringerModeAffectedStreams != mRingerModeAffectedStreams) {
                     /*
                      * Ensure all stream types that should be affected by ringer mode
diff --git a/media/java/android/media/videoeditor/MediaProperties.java b/media/java/android/media/videoeditor/MediaProperties.java
index a2e01f6..34186e9 100755
--- a/media/java/android/media/videoeditor/MediaProperties.java
+++ b/media/java/android/media/videoeditor/MediaProperties.java
@@ -198,6 +198,11 @@
     public static final int FILE_UNSUPPORTED = 255;
 
     /**
+     * Undefined video codec profiles
+     */
+    public static final int UNDEFINED_VIDEO_PROFILE = 255;
+
+    /**
      * The array of the supported file formats
      */
     private static final int[] SUPPORTED_VIDEO_FILE_FORMATS = new int[] {
diff --git a/media/java/android/media/videoeditor/MediaVideoItem.java b/media/java/android/media/videoeditor/MediaVideoItem.java
index bbadd62..d3505849 100755
--- a/media/java/android/media/videoeditor/MediaVideoItem.java
+++ b/media/java/android/media/videoeditor/MediaVideoItem.java
@@ -139,6 +139,11 @@
                 throw new IllegalArgumentException("Unsupported Video Codec Format in Input File");
         }
 
+        /* Check if the profile is unsupported. */
+        if (properties.profileAndLevel == MediaProperties.UNDEFINED_VIDEO_PROFILE) {
+            throw new IllegalArgumentException("Unsupported Video Codec Profile in Input File");
+        }
+
         mWidth = properties.width;
         mHeight = properties.height;
         mAspectRatio = mMANativeHelper.getAspectRatio(properties.width,
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index d144dba..2efb444 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -692,7 +692,7 @@
             boolean changed = setRotationUncheckedLocked(
                     WindowManagerPolicy.USE_LAST_ROTATION, 0, false);
             if (changed) {
-                sendNewConfiguration();
+                mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
             }
         }
 
@@ -11075,7 +11075,7 @@
             boolean changed = setRotationUncheckedLocked(
                     WindowManagerPolicy.USE_LAST_ROTATION, 0, false);
             if (changed) {
-                sendNewConfiguration();
+                mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
             }
         }