Fixes #1846038. DrawableContainer was wrongly returning its opacity by ignoring the visibility of the currently selected layer. This change simply reports a TRANSPARENT opacity if there is no currently selected layer of if the selected layer is not visible. Otherwise it reports the opacity computed by the state class.
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 410adb0..335b43c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4556,6 +4556,7 @@
      *
      * @hide Pending API council approval
      */
+    @ViewDebug.ExportedProperty
     public boolean isOpaque() {
         return mBGDrawable != null && mBGDrawable.getOpacity() == PixelFormat.OPAQUE;
     }
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index c4f0abd..edbb3db 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -823,7 +823,7 @@
             @ViewDebug.IntToString(from = RIGHT_OF,            to = "rightOf")
         }, mapping = {
             @ViewDebug.IntToString(from = TRUE, to = "true"),
-            @ViewDebug.IntToString(from = 0,    to = "NO_ID")
+            @ViewDebug.IntToString(from = 0,    to = "FALSE/NO_ID")
         })
         private int[] mRules = new int[VERB_COUNT];
 
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java
index 29f2a00..f8b88d0 100644
--- a/graphics/java/android/graphics/drawable/DrawableContainer.java
+++ b/graphics/java/android/graphics/drawable/DrawableContainer.java
@@ -181,7 +181,8 @@
 
     @Override
     public int getOpacity() {
-        return mDrawableContainerState.getOpacity();
+        return mCurrDrawable == null || !mCurrDrawable.isVisible() ? PixelFormat.TRANSPARENT :
+                mDrawableContainerState.getOpacity();
     }
 
     public boolean selectDrawable(int idx)
@@ -336,13 +337,11 @@
             return pos;
         }
 
-        public final int getChildCount()
-        {
+        public final int getChildCount() {
             return mNumChildren;
         }
 
-        public final Drawable[] getChildren()
-        {
+        public final Drawable[] getChildren() {
             return mDrawables;
         }
 
@@ -350,13 +349,11 @@
           * all frames in the set (false), or to use the padding value of the frame 
           * being shown (true). Default value is false. 
           */
-        public final void setVariablePadding(boolean variable)
-        {
+        public final void setVariablePadding(boolean variable) {
             mVariablePadding = variable;
         }
 
-        public final Rect getConstantPadding()
-        {
+        public final Rect getConstantPadding() {
             if (mVariablePadding) {
                 return null;
             }
@@ -364,11 +361,12 @@
                 return mConstantPadding;
             }
 
-            Rect r = new Rect(0, 0, 0, 0);
-            Rect t = new Rect();
+            final Rect r = new Rect(0, 0, 0, 0);
+            final Rect t = new Rect();
             final int N = getChildCount();
-            for (int i=0; i<N; i++) {
-                if (mDrawables[i].getPadding(t)) {
+            final Drawable[] drawables = mDrawables;
+            for (int i = 0; i < N; i++) {
+                if (drawables[i].getPadding(t)) {
                     if (t.left > r.left) r.left = t.left;
                     if (t.top > r.top) r.top = t.top;
                     if (t.right > r.right) r.right = t.right;
@@ -378,18 +376,15 @@
             return (mConstantPadding=r);
         }
 
-        public final void setConstantSize(boolean constant)
-        {
+        public final void setConstantSize(boolean constant) {
             mConstantSize = constant;
         }
 
-        public final boolean isConstantSize()
-        {
+        public final boolean isConstantSize() {
             return mConstantSize;
         }
 
-        public final int getConstantWidth()
-        {
+        public final int getConstantWidth() {
             if (!mComputedConstantSize) {
                 computeConstantSize();
             }
@@ -397,8 +392,7 @@
             return mConstantWidth;
         }
 
-        public final int getConstantHeight()
-        {
+        public final int getConstantHeight() {
             if (!mComputedConstantSize) {
                 computeConstantSize();
             }
@@ -406,8 +400,7 @@
             return mConstantHeight;
         }
 
-        public final int getConstantMinimumWidth()
-        {
+        public final int getConstantMinimumWidth() {
             if (!mComputedConstantSize) {
                 computeConstantSize();
             }
@@ -415,8 +408,7 @@
             return mConstantMinimumWidth;
         }
 
-        public final int getConstantMinimumHeight()
-        {
+        public final int getConstantMinimumHeight() {
             if (!mComputedConstantSize) {
                 computeConstantSize();
             }
@@ -424,15 +416,15 @@
             return mConstantMinimumHeight;
         }
 
-        private void computeConstantSize()
-        {
+        private void computeConstantSize() {
             mComputedConstantSize = true;
 
             final int N = getChildCount();
+            final Drawable[] drawables = mDrawables;
             mConstantWidth = mConstantHeight = 0;
             mConstantMinimumWidth = mConstantMinimumHeight = 0;
-            for (int i=0; i<N; i++) {
-                Drawable dr = mDrawables[i];
+            for (int i = 0; i < N; i++) {
+                Drawable dr = drawables[i];
                 int s = dr.getIntrinsicWidth();
                 if (s > mConstantWidth) mConstantWidth = s;
                 s = dr.getIntrinsicHeight();
@@ -444,23 +436,22 @@
             }
         }
 
-        public final int getOpacity()
-        {
+        public final int getOpacity() {
             if (mHaveOpacity) {
                 return mOpacity;
             }
 
             final int N = getChildCount();
-            int op = N > 0
-                ? mDrawables[0].getOpacity() : PixelFormat.TRANSPARENT;
-            for (int i=1; i<N; i++) {
-                op = Drawable.resolveOpacity(op, mDrawables[i].getOpacity());
+            final Drawable[] drawables = mDrawables;
+            int op = N > 0 ? drawables[0].getOpacity() : PixelFormat.TRANSPARENT;
+            for (int i = 1; i < N; i++) {
+                op = Drawable.resolveOpacity(op, drawables[i].getOpacity());
             }
             mOpacity = op;
             mHaveOpacity = true;
             return op;
         }
-        
+
         public final boolean isStateful() {
             if (mHaveStateful) {
                 return mStateful;
@@ -480,8 +471,7 @@
             return stateful;
         }
 
-        public void growArray(int oldSize, int newSize)
-        {
+        public void growArray(int oldSize, int newSize) {
             Drawable[] newDrawables = new Drawable[newSize];
             System.arraycopy(mDrawables, 0, newDrawables, 0, oldSize);
             mDrawables = newDrawables;