diff options
68 files changed, 944 insertions, 434 deletions
@@ -168910,52 +168910,6 @@ > </method> </class> -<class name="FileA3D.ClassID" - extends="java.lang.Enum" - abstract="false" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -<method name="toClassID" - return="android.renderscript.FileA3D.ClassID" - abstract="false" - native="false" - synchronized="false" - static="true" - final="false" - deprecated="not deprecated" - visibility="public" -> -<parameter name="intID" type="int"> -</parameter> -</method> -<method name="valueOf" - return="android.renderscript.FileA3D.ClassID" - abstract="false" - native="false" - synchronized="false" - static="true" - final="false" - deprecated="not deprecated" - visibility="public" -> -<parameter name="name" type="java.lang.String"> -</parameter> -</method> -<method name="values" - return="android.renderscript.FileA3D.ClassID[]" - abstract="false" - native="false" - synchronized="false" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</method> -</class> <class name="FileA3D.EntryType" extends="java.lang.Enum" abstract="false" @@ -168997,17 +168951,6 @@ deprecated="not deprecated" visibility="public" > -<method name="getClassID" - return="android.renderscript.FileA3D.ClassID" - abstract="false" - native="false" - synchronized="false" - static="false" - final="false" - deprecated="not deprecated" - visibility="public" -> -</method> <method name="getEntryType" return="android.renderscript.FileA3D.EntryType" abstract="false" diff --git a/api/current.xml b/api/current.xml index 0c33b8c..4a96512 100644 --- a/api/current.xml +++ b/api/current.xml @@ -7616,6 +7616,17 @@ visibility="public" > </field> +<field name="queryHint" + type="int" + transient="false" + volatile="false" + value="16843610" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="quickContactBadgeStyleSmallWindowLarge" type="int" transient="false" @@ -167165,7 +167176,7 @@ </parameter> <parameter name="type" type="android.renderscript.Type"> </parameter> -<parameter name="mc" type="android.renderscript.Allocation.MipmapControl"> +<parameter name="mips" type="android.renderscript.Allocation.MipmapControl"> </parameter> <parameter name="usage" type="int"> </parameter> @@ -169028,52 +169039,6 @@ > </method> </class> -<class name="FileA3D.ClassID" - extends="java.lang.Enum" - abstract="false" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -<method name="toClassID" - return="android.renderscript.FileA3D.ClassID" - abstract="false" - native="false" - synchronized="false" - static="true" - final="false" - deprecated="not deprecated" - visibility="public" -> -<parameter name="intID" type="int"> -</parameter> -</method> -<method name="valueOf" - return="android.renderscript.FileA3D.ClassID" - abstract="false" - native="false" - synchronized="false" - static="true" - final="false" - deprecated="not deprecated" - visibility="public" -> -<parameter name="name" type="java.lang.String"> -</parameter> -</method> -<method name="values" - return="android.renderscript.FileA3D.ClassID[]" - abstract="false" - native="false" - synchronized="false" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</method> -</class> <class name="FileA3D.EntryType" extends="java.lang.Enum" abstract="false" @@ -169115,17 +169080,6 @@ deprecated="not deprecated" visibility="public" > -<method name="getClassID" - return="android.renderscript.FileA3D.ClassID" - abstract="false" - native="false" - synchronized="false" - static="false" - final="false" - deprecated="not deprecated" - visibility="public" -> -</method> <method name="getEntryType" return="android.renderscript.FileA3D.EntryType" abstract="false" @@ -260215,7 +260169,7 @@ deprecated="not deprecated" visibility="public" > -<parameter name="t" type="T"> +<parameter name="arg0" type="T"> </parameter> </method> </interface> diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java index 21144f2..3280d39 100644 --- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java +++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java @@ -102,7 +102,6 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine private BluetoothDevice mDevice; private int mHeadsetState = BluetoothProfile.STATE_DISCONNECTED; private int mA2dpState = BluetoothProfile.STATE_DISCONNECTED; - private int mHidState = BluetoothProfile.STATE_DISCONNECTED; private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override @@ -140,7 +139,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine int newState = intent.getIntExtra(BluetoothInputDevice.EXTRA_INPUT_DEVICE_STATE, 0); int oldState = intent.getIntExtra(BluetoothInputDevice.EXTRA_PREVIOUS_INPUT_DEVICE_STATE, 0); - mHidState = newState; + if (oldState == BluetoothInputDevice.STATE_CONNECTED && newState == BluetoothInputDevice.STATE_DISCONNECTED) { sendMessage(DISCONNECT_HID_INCOMING); @@ -286,7 +285,8 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine sendMessage(DISCONNECT_A2DP_OUTGOING); deferMessage(message); break; - } else if (mHidState != BluetoothInputDevice.STATE_DISCONNECTED) { + } else if (mService.getInputDeviceState(mDevice) != + BluetoothInputDevice.STATE_DISCONNECTED) { sendMessage(DISCONNECT_HID_OUTGOING); deferMessage(message); break; diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java index e314fce..0f062cc 100644 --- a/core/java/android/os/StrictMode.java +++ b/core/java/android/os/StrictMode.java @@ -1632,7 +1632,6 @@ public final class StrictMode { */ public static void noteDiskRead() { BlockGuard.Policy policy = BlockGuard.getThreadPolicy(); - Log.d(TAG, "noteDiskRead; policy=" + policy); if (!(policy instanceof AndroidBlockGuardPolicy)) { // StrictMode not enabled. return; diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index 32e609c..dd88838 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -1755,7 +1755,8 @@ public class BluetoothService extends IBluetooth.Stub { "Need BLUETOOTH_ADMIN permission"); String objectPath = getObjectPathFromAddress(device.getAddress()); - if (objectPath == null || getConnectedInputDevices().size() == 0) { + if (objectPath == null || + getInputDeviceState(device) == BluetoothInputDevice.STATE_DISCONNECTED) { return false; } BluetoothDeviceProfileState state = mDeviceProfileState.get(device.getAddress()); diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index e81aa98..db2cd50 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -1550,6 +1550,7 @@ public final class MotionEvent extends InputEvent implements Parcelable { @Override public String toString() { return "MotionEvent{" + Integer.toHexString(System.identityHashCode(this)) + + " pointerId=" + getPointerId(0) + " action=" + actionToString(mAction) + " x=" + getX() + " y=" + getY() @@ -1567,6 +1568,8 @@ public final class MotionEvent extends InputEvent implements Parcelable { + " edgeFlags=0x" + Integer.toHexString(mEdgeFlags) + " device=" + mDeviceId + " source=0x" + Integer.toHexString(mSource) + + (getPointerCount() > 1 ? + " pointerId2=" + getPointerId(1) + " x2=" + getX(2) + " y2=" + getY(2) : "") + "}"; } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 45c35f0..c4bd1de 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -58,6 +58,7 @@ import android.util.PoolableManager; import android.util.Pools; import android.util.SparseArray; import android.view.ContextMenu.ContextMenuInfo; +import android.view.View.MeasureSpec; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEventSource; import android.view.accessibility.AccessibilityManager; @@ -3260,6 +3261,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * {@inheritDoc} */ public void sendAccessibilityEventUnchecked(AccessibilityEvent event) { + if (!isShown()) { + return; + } event.setClassName(getClass().getName()); event.setPackageName(getContext().getPackageName()); event.setEnabled(isEnabled()); @@ -7822,6 +7826,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * * <p>Note: if this view's parent addStateFromChildren property is enabled and this * property is enabled, an exception will be thrown.</p> + * + * <p>Note: if the child view uses and updates additionnal states which are unknown to the + * parent, these states should not be affected by this method.</p> * * @param enabled True to enable duplication of the parent's drawable state, false * to disable it. diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index cb0a2a9..e8d67da 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -23,6 +23,9 @@ import android.os.IBinder; import android.os.LocalPowerManager; import android.view.animation.Animation; +import java.io.FileDescriptor; +import java.io.PrintWriter; + /** * This interface supplies all UI-specific behavior of the window manager. An * instance of it is created by the window manager when it starts up, and allows @@ -817,4 +820,15 @@ public interface WindowManagerPolicy { * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}. */ public void setUserRotationMode(int mode, int rotation); + + /** + * Print the WindowManagerPolicy's state into the given stream. + * + * @param prefix Text to print at the front of each line. + * @param fd The raw file descriptor that the dump is being sent to. + * @param writer The PrintWriter to which you should dump your state. This will be + * closed for you after you return. + * @param args additional arguments to the dump request. + */ + public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args); } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index b893af8..43e7ef6 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -5471,6 +5471,8 @@ public class WebView extends AbsoluteLayout if (shouldForwardTouchEvent()) { TouchEventData ted = new TouchEventData(); ted.mAction = action; + ted.mIds = new int[1]; + ted.mIds[0] = ev.getPointerId(0); ted.mPoints = new Point[1]; ted.mPoints[0] = new Point(contentX, contentY); ted.mMetaState = ev.getMetaState(); @@ -5513,6 +5515,8 @@ public class WebView extends AbsoluteLayout || eventTime - mLastSentTouchTime > mCurrentTouchInterval)) { TouchEventData ted = new TouchEventData(); ted.mAction = action; + ted.mIds = new int[1]; + ted.mIds[0] = ev.getPointerId(0); ted.mPoints = new Point[1]; ted.mPoints[0] = new Point(contentX, contentY); ted.mMetaState = ev.getMetaState(); @@ -5682,6 +5686,8 @@ public class WebView extends AbsoluteLayout // pass the touch events from UI thread to WebCore thread if (shouldForwardTouchEvent()) { TouchEventData ted = new TouchEventData(); + ted.mIds = new int[1]; + ted.mIds[0] = ev.getPointerId(0); ted.mAction = action; ted.mPoints = new Point[1]; ted.mPoints[0] = new Point(contentX, contentY); @@ -5699,6 +5705,8 @@ public class WebView extends AbsoluteLayout mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS); if (inFullScreenMode() || mDeferTouchProcess) { TouchEventData ted = new TouchEventData(); + ted.mIds = new int[1]; + ted.mIds[0] = ev.getPointerId(0); ted.mAction = WebViewCore.ACTION_DOUBLETAP; ted.mPoints = new Point[1]; ted.mPoints[0] = new Point(contentX, contentY); @@ -5832,8 +5840,10 @@ public class WebView extends AbsoluteLayout TouchEventData ted = new TouchEventData(); ted.mAction = ev.getAction() & MotionEvent.ACTION_MASK; final int count = ev.getPointerCount(); + ted.mIds = new int[count]; ted.mPoints = new Point[count]; for (int c = 0; c < count; c++) { + ted.mIds[c] = ev.getPointerId(c); int x = viewToContentX((int) ev.getX(c) + mScrollX); int y = viewToContentY((int) ev.getY(c) + mScrollY); ted.mPoints[c] = new Point(x, y); @@ -5927,6 +5937,8 @@ public class WebView extends AbsoluteLayout mWebViewCore.removeMessages(EventHub.TOUCH_EVENT); } TouchEventData ted = new TouchEventData(); + ted.mIds = new int[1]; + ted.mIds[0] = 0; ted.mPoints = new Point[1]; ted.mPoints[0] = new Point(x, y); ted.mAction = MotionEvent.ACTION_CANCEL; @@ -7054,6 +7066,8 @@ public class WebView extends AbsoluteLayout if (inFullScreenMode() || mDeferTouchProcess) { TouchEventData ted = new TouchEventData(); ted.mAction = WebViewCore.ACTION_LONGPRESS; + ted.mIds = new int[1]; + ted.mIds[0] = 0; ted.mPoints = new Point[1]; ted.mPoints[0] = new Point(viewToContentX((int) mLastTouchX + mScrollX), viewToContentY((int) mLastTouchY + mScrollY)); diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 2ea20ee..c56f252 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -562,8 +562,8 @@ final class WebViewCore { private native void nativeTouchUp(int touchGeneration, int framePtr, int nodePtr, int x, int y); - private native boolean nativeHandleTouchEvent(int action, int[] x, int[] y, - int count, int metaState); + private native boolean nativeHandleTouchEvent(int action, int[] idArray, + int[] xArray, int[] yArray, int count, int metaState); private native void nativeUpdateFrameCache(); @@ -828,6 +828,7 @@ final class WebViewCore { static class TouchEventData { int mAction; + int[] mIds; // Ids of the touch points Point[] mPoints; int mMetaState; boolean mReprocess; @@ -1336,8 +1337,8 @@ final class WebViewCore { mWebView.mPrivateHandler, WebView.PREVENT_TOUCH_ID, ted.mAction, - nativeHandleTouchEvent(ted.mAction, xArray, - yArray, count, ted.mMetaState) ? 1 : 0, + nativeHandleTouchEvent(ted.mAction, ted.mIds, + xArray, yArray, count, ted.mMetaState) ? 1 : 0, ted.mReprocess ? ted : null).sendToTarget(); break; } diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index 3bf5af3..2c96056 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -217,6 +217,10 @@ public class SearchView extends LinearLayout { if (maxWidth != -1) { setMaxWidth(maxWidth); } + CharSequence queryHint = a.getText(R.styleable.SearchView_queryHint); + if (!TextUtils.isEmpty(queryHint)) { + setQueryHint(queryHint); + } a.recycle(); // Save voice intent for later queries/launching diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b892fe2..623cd41 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -4135,9 +4135,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @Override protected int[] onCreateDrawableState(int extraSpace) { - final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); + final int[] drawableState; - if (!mSingleLine) { + if (mSingleLine) { + drawableState = super.onCreateDrawableState(extraSpace); + } else { + drawableState = super.onCreateDrawableState(extraSpace + 1); mergeDrawableStates(drawableState, MULTILINE_STATE_SET); } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 3a3ca36..a29f417 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -4664,6 +4664,8 @@ <attr name="iconifiedByDefault" format="boolean"/> <!-- An optional maximum width of the SearchView. --> <attr name="maxWidth" /> + <!-- An optional query hint string to be displayed in the empty query field. --> + <attr name="queryHint" format="string" /> </declare-styleable> <declare-styleable name="ActionBar_LayoutParams"> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 6d79569..a4834b2 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1424,6 +1424,7 @@ <public type="attr" name="alertDialogIcon" /> <public type="attr" name="windowMinWidthMajor" /> <public type="attr" name="windowMinWidthMinor" /> + <public type="attr" name="queryHint" /> <!-- A simple fade-in animation. --> <public type="animator" name="fade_in" id="0x010b0000" /> diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index b15121a..579f314 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -503,7 +503,7 @@ public class Allocation extends BaseObj { * Creates a renderscript allocation with the size specified by * the type and no mipmaps generated by default * - * @param rs + * @param rs Context to which the allocation will belong. * @param type renderscript type describing data layout * @param usage bit field specifying how the allocation is * utilized @@ -519,7 +519,7 @@ public class Allocation extends BaseObj { * the size specified by the type and no mipmaps generated by * default * - * @param rs + * @param rs Context to which the allocation will belong. * @param type renderscript type describing data layout * * @return allocation @@ -532,7 +532,7 @@ public class Allocation extends BaseObj { * Creates a renderscript allocation with a specified number of * given elements * - * @param rs + * @param rs Context to which the allocation will belong. * @param e describes what each element of an allocation is * @param count specifies the number of element in the allocation * @param usage bit field specifying how the allocation is @@ -558,7 +558,7 @@ public class Allocation extends BaseObj { * Creates a renderscript allocation with a specified number of * given elements * - * @param rs + * @param rs Context to which the allocation will belong. * @param e describes what each element of an allocation is * @param count specifies the number of element in the allocation * @@ -598,7 +598,7 @@ public class Allocation extends BaseObj { /** * Creates a renderscript allocation from a bitmap * - * @param rs + * @param rs Context to which the allocation will belong. * @param b bitmap source for the allocation data * @param mips specifies desired mipmap behaviour for the * allocation @@ -625,7 +625,7 @@ public class Allocation extends BaseObj { * Creates a non-mipmapped renderscript allocation to use as a * graphics texture * - * @param rs + * @param rs Context to which the allocation will belong. * @param b bitmap source for the allocation data * * @return renderscript allocation containing bitmap data @@ -641,7 +641,7 @@ public class Allocation extends BaseObj { * horizontal list of cube faces. Each individual face must be * the same size and power of 2 * - * @param rs + * @param rs Context to which the allocation will belong. * @param b bitmap with cubemap faces layed out in the following * format: right, left, top, bottom, front, back * @param mips specifies desired mipmap behaviour for the cubemap @@ -690,7 +690,7 @@ public class Allocation extends BaseObj { * of cube faces. Each individual face must be the same size and * power of 2 * - * @param rs + * @param rs Context to which the allocation will belong. * @param b bitmap with cubemap faces layed out in the following * format: right, left, top, bottom, front, back * @@ -708,7 +708,7 @@ public class Allocation extends BaseObj { * the cube faces. All the faces must be the same size and * power of 2 * - * @param rs + * @param rs Context to which the allocation will belong. * @param xpos cubemap face in the positive x direction * @param xneg cubemap face in the negative x direction * @param ypos cubemap face in the positive y direction @@ -776,7 +776,7 @@ public class Allocation extends BaseObj { * the cube faces. All the faces must be the same size and * power of 2 * - * @param rs + * @param rs Context to which the allocation will belong. * @param xpos cubemap face in the positive x direction * @param xneg cubemap face in the negative x direction * @param ypos cubemap face in the positive y direction @@ -803,7 +803,7 @@ public class Allocation extends BaseObj { * Creates a renderscript allocation from the bitmap referenced * by resource id * - * @param rs + * @param rs Context to which the allocation will belong. * @param res application resources * @param id resource id to load the data from * @param mips specifies desired mipmap behaviour for the @@ -831,7 +831,7 @@ public class Allocation extends BaseObj { * Creates a non-mipmapped renderscript allocation to use as a * graphics texture from the bitmap referenced by resource id * - * @param rs + * @param rs Context to which the allocation will belong. * @param res application resources * @param id resource id to load the data from * @@ -850,7 +850,7 @@ public class Allocation extends BaseObj { * Creates a renderscript allocation containing string data * encoded in UTF-8 format * - * @param rs + * @param rs Context to which the allocation will belong. * @param str string to create the allocation from * @param usage bit field specifying how the allocaiton is * utilized diff --git a/graphics/java/android/renderscript/FileA3D.java b/graphics/java/android/renderscript/FileA3D.java index 90d102c..fe3971a 100644 --- a/graphics/java/android/renderscript/FileA3D.java +++ b/graphics/java/android/renderscript/FileA3D.java @@ -28,22 +28,22 @@ import android.util.Log; import android.util.TypedValue; /** + * FileA3D allows users to load renderscript objects from files + * or resources stored on disk. It could be used to load items + * such as 3d geometry data converted a renderscript format from + * content creation tools. Currently only meshes are supported + * in FileA3D. + * + * When successfully loaded, FileA3D will contain a list of + * index entries for all the objects stored inside it. * **/ public class FileA3D extends BaseObj { - // This will go away in the clean up pass, - // trying to avoid multiproject submits - public enum ClassID { - - UNKNOWN, - MESH; - - public static ClassID toClassID(int intID) { - return ClassID.values()[intID]; - } - } - + /** + * Specifies what renderscript object type is contained within + * the FileA3D IndexEntry + **/ public enum EntryType { UNKNOWN (0), @@ -59,34 +59,48 @@ public class FileA3D extends BaseObj { } } - // Read only class with index entries + /** + * IndexEntry contains information about one of the renderscript + * objects inside the file's index. It could be used to query the + * object's type and name and load the object itself if + * necessary. + */ public static class IndexEntry { RenderScript mRS; int mIndex; int mID; String mName; - ClassID mClassID; EntryType mEntryType; BaseObj mLoadedObj; + /** + * @return name of a renderscript object the index entry + * describes + */ public String getName() { return mName; } - public ClassID getClassID() { - return mClassID; - } - + /** + * @return type of a renderscript object the index entry + * describes + */ public EntryType getEntryType() { return mEntryType; } + /** + * @return renderscript object described by the entry + */ public BaseObj getObject() { mRS.validate(); BaseObj obj = internalCreate(mRS, this); return obj; } + /** + * @return renderscript mesh object described by the entry + */ public Mesh getMesh() { return (Mesh)getObject(); } @@ -122,7 +136,6 @@ public class FileA3D extends BaseObj { mID = id; mName = name; mEntryType = type; - mClassID = mEntryType == EntryType.MESH ? ClassID.MESH : ClassID.UNKNOWN; mLoadedObj = null; } } @@ -152,6 +165,9 @@ public class FileA3D extends BaseObj { } } + /** + * @return the numberof objects stored inside a FileA3D + */ public int getIndexEntryCount() { if(mFileEntries == null) { return 0; @@ -159,6 +175,12 @@ public class FileA3D extends BaseObj { return mFileEntries.length; } + /** + * Returns an index entry from the list of all objects inside + * FileA3D + * + * @param index number of the entry from the list to return + */ public IndexEntry getIndexEntry(int index) { if(getIndexEntryCount() == 0 || index < 0 || index >= mFileEntries.length) { return null; @@ -166,6 +188,14 @@ public class FileA3D extends BaseObj { return mFileEntries[index]; } + /** + * Creates a FileA3D object from an asset stored on disk + * + * @param rs Context to which the object will belong. + * @param mgr asset manager used to load asset + * @param path location of the file to load + * + */ static public FileA3D createFromAsset(RenderScript rs, AssetManager mgr, String path) { rs.validate(); int fileId = rs.nFileA3DCreateFromAsset(mgr, path); @@ -178,6 +208,13 @@ public class FileA3D extends BaseObj { return fa3d; } + /** + * Creates a FileA3D object from a file stored on disk + * + * @param rs Context to which the object will belong. + * @param path location of the file to load + * + */ static public FileA3D createFromFile(RenderScript rs, String path) { int fileId = rs.nFileA3DCreateFromFile(path); @@ -189,10 +226,25 @@ public class FileA3D extends BaseObj { return fa3d; } + /** + * Creates a FileA3D object from a file stored on disk + * + * @param rs Context to which the object will belong. + * @param path location of the file to load + * + */ static public FileA3D createFromFile(RenderScript rs, File path) { return createFromFile(rs, path.getAbsolutePath()); } + /** + * Creates a FileA3D object from an application resource + * + * @param rs Context to which the object will belong. + * @param res resource manager used for loading + * @param id resource to create FileA3D from + * + */ static public FileA3D createFromResource(RenderScript rs, Resources res, int id) { rs.validate(); diff --git a/graphics/java/android/renderscript/Mesh.java b/graphics/java/android/renderscript/Mesh.java index f1f1237..fcf8178 100644 --- a/graphics/java/android/renderscript/Mesh.java +++ b/graphics/java/android/renderscript/Mesh.java @@ -172,7 +172,7 @@ public class Mesh extends BaseObj { /** * Creates builder object - * @param rs + * @param rs Context to which the mesh will belong. * @param usage specifies how the mesh allocations are to be * handled, whether they need to be uploaded to a * buffer on the gpu, maintain a cpu copy, etc @@ -512,7 +512,7 @@ public class Mesh extends BaseObj { public static final int TEXTURE_0 = 0x0100; /** - * @param rs + * @param rs Context to which the mesh will belong. * @param vtxSize specifies whether the vertex is a float2 or * float3 * @param flags bitfield that is a combination of COLOR, NORMAL, diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java index 14c0c01..333880d 100644 --- a/graphics/java/android/renderscript/ProgramFragment.java +++ b/graphics/java/android/renderscript/ProgramFragment.java @@ -36,7 +36,7 @@ public class ProgramFragment extends Program { /** * Create a builder object. * - * @param rs + * @param rs Context to which the program will belong. */ public Builder(RenderScript rs) { super(rs); diff --git a/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java b/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java index 663bc9f..1af31f8 100644 --- a/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java +++ b/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java @@ -194,7 +194,7 @@ public class ProgramFragmentFixedFunction extends ProgramFragment { /** * Creates a builder for fixed function fragment program * - * @param rs + * @param rs Context to which the program will belong. */ public Builder(RenderScript rs) { mRS = rs; diff --git a/graphics/java/android/renderscript/ProgramStore.java b/graphics/java/android/renderscript/ProgramStore.java index d79900e..9128f9b 100644 --- a/graphics/java/android/renderscript/ProgramStore.java +++ b/graphics/java/android/renderscript/ProgramStore.java @@ -149,7 +149,7 @@ public class ProgramStore extends BaseObj { * - incoming pixels override the value stored in the color * buffer if it passes the depth test * - * @param rs + * @param rs Context to which the program will belong. **/ public static ProgramStore BLEND_NONE_DEPTH_TEST(RenderScript rs) { if(rs.mProgramStore_BLEND_NONE_DEPTH_TEST == null) { @@ -170,7 +170,7 @@ public class ProgramStore extends BaseObj { * - incoming pixels override the value stored in the color * buffer * - * @param rs + * @param rs Context to which the program will belong. **/ public static ProgramStore BLEND_NONE_DEPTH_NONE(RenderScript rs) { if(rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH == null) { @@ -194,7 +194,7 @@ public class ProgramStore extends BaseObj { * following formula * Final.RGB = Source.RGB * Source.A + Dest.RGB * (1 - Source.A) * - * @param rs + * @param rs Context to which the program will belong. **/ public static ProgramStore BLEND_ALPHA_DEPTH_TEST(RenderScript rs) { if(rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST == null) { @@ -216,7 +216,7 @@ public class ProgramStore extends BaseObj { * (Dest) using the following formula * Final.RGB = Source.RGB * Source.A + Dest.RGB * (1 - Source.A) * - * @param rs + * @param rs Context to which the program will belong. **/ public static ProgramStore BLEND_ALPHA_DEPTH_NONE(RenderScript rs) { if(rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH == null) { diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java index 7ba8b82..a965b81 100644 --- a/graphics/java/android/renderscript/ProgramVertex.java +++ b/graphics/java/android/renderscript/ProgramVertex.java @@ -46,7 +46,7 @@ public class ProgramVertex extends Program { /** * Create a builder object. * - * @param rs + * @param rs Context to which the program will belong. */ public Builder(RenderScript rs) { super(rs); diff --git a/graphics/java/android/renderscript/ProgramVertexFixedFunction.java b/graphics/java/android/renderscript/ProgramVertexFixedFunction.java index b9537c7..666c7ec 100644 --- a/graphics/java/android/renderscript/ProgramVertexFixedFunction.java +++ b/graphics/java/android/renderscript/ProgramVertexFixedFunction.java @@ -105,7 +105,7 @@ public class ProgramVertexFixedFunction extends ProgramVertex { /** * Creates a builder for fixed function vertex program * - * @param rs + * @param rs Context to which the program will belong. */ public Builder(RenderScript rs) { mRS = rs; @@ -196,9 +196,9 @@ public class ProgramVertexFixedFunction extends ProgramVertex { private FieldPacker mIOBuffer; /** - * Creates buffer to store fixed function emulation matrices + * Creates a buffer to store fixed function emulation matrices * - * @param rs + * @param rs Context to which the allocation will belong. **/ public Constants(RenderScript rs) { Type constInputType = ProgramVertexFixedFunction.Builder.getConstantInputType(rs); diff --git a/graphics/java/android/renderscript/Sampler.java b/graphics/java/android/renderscript/Sampler.java index 57a9889..c656d75 100644 --- a/graphics/java/android/renderscript/Sampler.java +++ b/graphics/java/android/renderscript/Sampler.java @@ -56,7 +56,7 @@ public class Sampler extends BaseObj { * Retrieve a sampler with min and mag set to nearest and wrap modes set to * clamp. * - * @param rs + * @param rs Context to which the sampler will belong. * * @return Sampler */ @@ -76,7 +76,7 @@ public class Sampler extends BaseObj { * Retrieve a sampler with min and mag set to linear and wrap modes set to * clamp. * - * @param rs + * @param rs Context to which the sampler will belong. * * @return Sampler */ @@ -96,7 +96,7 @@ public class Sampler extends BaseObj { * Retrieve a sampler with ag set to linear, min linear mipmap linear, and * to and wrap modes set to clamp. * - * @param rs + * @param rs Context to which the sampler will belong. * * @return Sampler */ @@ -116,7 +116,7 @@ public class Sampler extends BaseObj { * Retrieve a sampler with min and mag set to nearest and wrap modes set to * wrap. * - * @param rs + * @param rs Context to which the sampler will belong. * * @return Sampler */ @@ -136,7 +136,7 @@ public class Sampler extends BaseObj { * Retrieve a sampler with min and mag set to nearest and wrap modes set to * wrap. * - * @param rs + * @param rs Context to which the sampler will belong. * * @return Sampler */ @@ -156,7 +156,7 @@ public class Sampler extends BaseObj { * Retrieve a sampler with ag set to linear, min linear mipmap linear, and * to and wrap modes set to wrap. * - * @param rs + * @param rs Context to which the sampler will belong. * * @return Sampler */ diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h index 09cf2a2..002e48b 100644 --- a/include/gui/SurfaceTexture.h +++ b/include/gui/SurfaceTexture.h @@ -26,12 +26,15 @@ #include <ui/GraphicBuffer.h> #include <utils/threads.h> +#include <utils/Vector.h> #define ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID "mSurfaceTexture" namespace android { // ---------------------------------------------------------------------------- +class IGraphicBufferAlloc; + class SurfaceTexture : public BnSurfaceTexture { public: enum { MIN_BUFFER_SLOTS = 3 }; @@ -140,6 +143,12 @@ private: // reset mCurrentTexture to INVALID_BUFFER_SLOT. int mCurrentTexture; + // mCurrentTextureBuf is the graphic buffer of the current texture. It's + // possible that this buffer is not associated with any buffer slot, so we + // must track it separately in order to properly use + // IGraphicBufferAlloc::freeAllGraphicBuffersExcept. + sp<GraphicBuffer> mCurrentTextureBuf; + // mCurrentCrop is the crop rectangle that applies to the current texture. // It gets set to mLastQueuedCrop each time updateTexImage is called. Rect mCurrentCrop; @@ -176,6 +185,16 @@ private: // changed with a call to setTexName. const GLuint mTexName; + // mGraphicBufferAlloc is the connection to SurfaceFlinger that is used to + // allocate new GraphicBuffer objects. + sp<IGraphicBufferAlloc> mGraphicBufferAlloc; + + // mAllocdBuffers is mirror of the list of buffers that SurfaceFlinger is + // referencing. This is kept so that gralloc implementations do not need to + // properly handle the case where SurfaceFlinger no longer holds a reference + // to a buffer, but other processes do. + Vector<sp<GraphicBuffer> > mAllocdBuffers; + // mMutex is the mutex used to prevent concurrent access to the member // variables of SurfaceTexture objects. It must be locked whenever the // member variables are accessed. diff --git a/include/surfaceflinger/IGraphicBufferAlloc.h b/include/surfaceflinger/IGraphicBufferAlloc.h new file mode 100644 index 0000000..d996af7 --- /dev/null +++ b/include/surfaceflinger/IGraphicBufferAlloc.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_SF_IGRAPHIC_BUFFER_ALLOC_H +#define ANDROID_SF_IGRAPHIC_BUFFER_ALLOC_H + +#include <stdint.h> +#include <sys/types.h> + +#include <utils/RefBase.h> + +#include <binder/IInterface.h> + +namespace android { +// ---------------------------------------------------------------------------- + +class IGraphicBufferAlloc : public IInterface +{ +public: + DECLARE_META_INTERFACE(GraphicBufferAlloc); + + /* Create a new GraphicBuffer for the client to use. The server will + * maintain a reference to the newly created GraphicBuffer until + * freeAllGraphicBuffers is called. + */ + virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, + PixelFormat format, uint32_t usage) = 0; + + /* Free all but one of the GraphicBuffer objects that the server is + * currently referencing. If bufIndex is not a valid index of the buffers + * the server is referencing, then all buffers are freed. + */ + virtual void freeAllGraphicBuffersExcept(int bufIndex) = 0; +}; + +// ---------------------------------------------------------------------------- + +class BnGraphicBufferAlloc : public BnInterface<IGraphicBufferAlloc> +{ +public: + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +// ---------------------------------------------------------------------------- + +}; // namespace android + +#endif // ANDROID_SF_IGRAPHIC_BUFFER_ALLOC_H diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h index 1bab7d7..56ed3a4 100644 --- a/include/surfaceflinger/ISurfaceComposer.h +++ b/include/surfaceflinger/ISurfaceComposer.h @@ -28,6 +28,7 @@ #include <ui/PixelFormat.h> #include <surfaceflinger/ISurfaceComposerClient.h> +#include <surfaceflinger/IGraphicBufferAlloc.h> namespace android { // ---------------------------------------------------------------------------- @@ -96,6 +97,10 @@ public: */ virtual sp<ISurfaceComposerClient> createClientConnection() = 0; + /* create a graphic buffer allocator + */ + virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0; + /* retrieve the control block */ virtual sp<IMemoryHeap> getCblk() const = 0; @@ -131,13 +136,6 @@ public: * This is an ASYNCHRONOUS call. */ virtual void signal() const = 0; - - /* Create a new GraphicBuffer for the client to use. SurfaceFlinger will - * not maintain a reference to the GraphicBuffer, so the underlying native - * handle will be freed once the client references are released. - */ - virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, - PixelFormat format, uint32_t usage) const = 0; }; // ---------------------------------------------------------------------------- @@ -151,7 +149,7 @@ public: BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION, CREATE_CONNECTION, CREATE_CLIENT_CONNECTION, - CREATE_GRAPHIC_BUFFER, + CREATE_GRAPHIC_BUFFER_ALLOC, GET_CBLK, OPEN_GLOBAL_TRANSACTION, CLOSE_GLOBAL_TRANSACTION, diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index 1389ed6..447de76 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -29,6 +29,7 @@ #include <surfaceflinger/ISurfaceComposer.h> #include <surfaceflinger/SurfaceComposerClient.h> +#include <surfaceflinger/IGraphicBufferAlloc.h> #include <utils/Log.h> @@ -83,6 +84,8 @@ SurfaceTexture::SurfaceTexture(GLuint tex) : mSlots[i].mEglDisplay = EGL_NO_DISPLAY; mSlots[i].mOwnedByClient = false; } + sp<ISurfaceComposer> composer(ComposerService::getComposerService()); + mGraphicBufferAlloc = composer->createGraphicBufferAlloc(); } SurfaceTexture::~SurfaceTexture() { @@ -110,9 +113,8 @@ sp<GraphicBuffer> SurfaceTexture::requestBuffer(int buf, return 0; } usage |= GraphicBuffer::USAGE_HW_TEXTURE; - sp<ISurfaceComposer> composer(ComposerService::getComposerService()); - sp<GraphicBuffer> graphicBuffer(composer->createGraphicBuffer(w, h, - format, usage)); + sp<GraphicBuffer> graphicBuffer( + mGraphicBufferAlloc->createGraphicBuffer(w, h, format, usage)); if (graphicBuffer == 0) { LOGE("requestBuffer: SurfaceComposer::createGraphicBuffer failed"); } else { @@ -122,6 +124,7 @@ sp<GraphicBuffer> SurfaceTexture::requestBuffer(int buf, mSlots[buf].mEglImage = EGL_NO_IMAGE_KHR; mSlots[buf].mEglDisplay = EGL_NO_DISPLAY; } + mAllocdBuffers.add(graphicBuffer); } return graphicBuffer; } @@ -204,27 +207,28 @@ status_t SurfaceTexture::updateTexImage() { // Initially both mCurrentTexture and mLastQueued are INVALID_BUFFER_SLOT, // so this check will fail until a buffer gets queued. if (mCurrentTexture != mLastQueued) { - // Update the SurfaceTexture state. - mCurrentTexture = mLastQueued; - mCurrentCrop = mLastQueuedCrop; - mCurrentTransform = mLastQueuedTransform; - // Update the GL texture object. - EGLImageKHR image = mSlots[mCurrentTexture].mEglImage; + EGLImageKHR image = mSlots[mLastQueued].mEglImage; if (image == EGL_NO_IMAGE_KHR) { EGLDisplay dpy = eglGetCurrentDisplay(); - sp<GraphicBuffer> graphicBuffer = mSlots[mCurrentTexture].mGraphicBuffer; + sp<GraphicBuffer> graphicBuffer = mSlots[mLastQueued].mGraphicBuffer; image = createImage(dpy, graphicBuffer); - mSlots[mCurrentTexture].mEglImage = image; - mSlots[mCurrentTexture].mEglDisplay = dpy; + mSlots[mLastQueued].mEglImage = image; + mSlots[mLastQueued].mEglDisplay = dpy; } glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, (GLeglImageOES)image); GLint error = glGetError(); if (error != GL_NO_ERROR) { LOGE("error binding external texture image %p (slot %d): %#04x", - image, mCurrentTexture, error); + image, mLastQueued, error); return -EINVAL; } + + // Update the SurfaceTexture state. + mCurrentTexture = mLastQueued; + mCurrentTextureBuf = mSlots[mCurrentTexture].mGraphicBuffer; + mCurrentCrop = mLastQueuedCrop; + mCurrentTransform = mLastQueuedTransform; } return OK; } @@ -282,6 +286,19 @@ void SurfaceTexture::freeAllBuffers() { mSlots[i].mEglDisplay = EGL_NO_DISPLAY; } } + + int exceptBuf = -1; + for (size_t i = 0; i < mAllocdBuffers.size(); i++) { + if (mAllocdBuffers[i] == mCurrentTextureBuf) { + exceptBuf = i; + break; + } + } + mAllocdBuffers.clear(); + if (exceptBuf >= 0) { + mAllocdBuffers.add(mCurrentTextureBuf); + } + mGraphicBufferAlloc->freeAllGraphicBuffersExcept(exceptBuf); } EGLImageKHR SurfaceTexture::createImage(EGLDisplay dpy, diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index 8a59144..24cee24 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -15,6 +15,7 @@ */ #define LOG_TAG "SurfaceTextureClient" +//#define LOG_NDEBUG 0 #include <gui/SurfaceTextureClient.h> @@ -82,10 +83,12 @@ int SurfaceTextureClient::setSwapInterval(int interval) { } int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) { + LOGV("SurfaceTextureClient::dequeueBuffer"); Mutex::Autolock lock(mMutex); int buf = -1; status_t err = mSurfaceTexture->dequeueBuffer(&buf); if (err < 0) { + LOGE("dequeueBuffer: ISurfaceTexture::dequeueBuffer failed: %d", err); return err; } sp<GraphicBuffer>& gbuf(mSlots[buf]); @@ -96,6 +99,7 @@ int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) { gbuf = mSurfaceTexture->requestBuffer(buf, mReqWidth, mReqHeight, mReqFormat, mReqUsage); if (gbuf == 0) { + LOGE("dequeueBuffer: ISurfaceTexture::requestBuffer failed"); return NO_MEMORY; } } @@ -104,6 +108,7 @@ int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) { } int SurfaceTextureClient::cancelBuffer(android_native_buffer_t* buffer) { + LOGV("SurfaceTextureClient::cancelBuffer"); Mutex::Autolock lock(mMutex); for (int i = 0; i < NUM_BUFFER_SLOTS; i++) { if (mSlots[i].get() == buffer) { @@ -115,11 +120,13 @@ int SurfaceTextureClient::cancelBuffer(android_native_buffer_t* buffer) { } int SurfaceTextureClient::lockBuffer(android_native_buffer_t* buffer) { + LOGV("SurfaceTextureClient::lockBuffer"); Mutex::Autolock lock(mMutex); return OK; } int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) { + LOGV("SurfaceTextureClient::queueBuffer"); Mutex::Autolock lock(mMutex); for (int i = 0; i < NUM_BUFFER_SLOTS; i++) { if (mSlots[i].get() == GraphicBuffer::getSelf(buffer)) { @@ -131,6 +138,7 @@ int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) { } int SurfaceTextureClient::query(int what, int* value) { + LOGV("SurfaceTextureClient::query"); Mutex::Autolock lock(mMutex); // XXX: Implement this! return INVALID_OPERATION; @@ -206,17 +214,20 @@ int SurfaceTextureClient::dispatchSetBuffersTransform(va_list args) { } int SurfaceTextureClient::connect(int api) { + LOGV("SurfaceTextureClient::connect"); // XXX: Implement this! return INVALID_OPERATION; } int SurfaceTextureClient::disconnect(int api) { + LOGV("SurfaceTextureClient::disconnect"); // XXX: Implement this! return INVALID_OPERATION; } int SurfaceTextureClient::setUsage(uint32_t reqUsage) { + LOGV("SurfaceTextureClient::setUsage"); Mutex::Autolock lock(mMutex); mReqUsage = reqUsage; return OK; @@ -224,6 +235,7 @@ int SurfaceTextureClient::setUsage(uint32_t reqUsage) int SurfaceTextureClient::setCrop(Rect const* rect) { + LOGV("SurfaceTextureClient::setCrop"); Mutex::Autolock lock(mMutex); // empty/invalid rects are not allowed @@ -239,6 +251,7 @@ int SurfaceTextureClient::setCrop(Rect const* rect) int SurfaceTextureClient::setBufferCount(int bufferCount) { + LOGV("SurfaceTextureClient::setBufferCount"); Mutex::Autolock lock(mMutex); status_t err = mSurfaceTexture->setBufferCount(bufferCount); @@ -254,6 +267,7 @@ int SurfaceTextureClient::setBufferCount(int bufferCount) int SurfaceTextureClient::setBuffersGeometry(int w, int h, int format) { + LOGV("SurfaceTextureClient::setBuffersGeometry"); Mutex::Autolock lock(mMutex); if (w<0 || h<0 || format<0) @@ -271,6 +285,7 @@ int SurfaceTextureClient::setBuffersGeometry(int w, int h, int format) int SurfaceTextureClient::setBuffersTransform(int transform) { + LOGV("SurfaceTextureClient::setBuffersTransform"); Mutex::Autolock lock(mMutex); status_t err = mSurfaceTexture->setTransform(transform); return err; diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h index a194cbe..bdd8e73 100644 --- a/libs/hwui/Debug.h +++ b/libs/hwui/Debug.h @@ -47,4 +47,7 @@ // Turn on to display debug info about the layer renderer #define DEBUG_LAYER_RENDERER 0 +// Turn on to dump display list state +#define DEBUG_DISPLAY_LIST 0 + #endif // ANDROID_HWUI_DEBUG_H diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 57df976..75b1671 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -81,6 +81,39 @@ void PathHeap::flatten(SkFlattenableWriteBuffer& buffer) const { // Display list /////////////////////////////////////////////////////////////////////////////// +const char* DisplayList::OP_NAMES[] = { + "AcquireContext", + "ReleaseContext", + "Save", + "Restore", + "RestoreToCount", + "SaveLayer", + "SaveLayerAlpha", + "Translate", + "Rotate", + "Scale", + "SetMatrix", + "ConcatMatrix", + "ClipRect", + "DrawDisplayList", + "DrawLayer", + "DrawBitmap", + "DrawBitmapMatrix", + "DrawBitmapRect", + "DrawPatch", + "DrawColor", + "DrawRect", + "DrawPath", + "DrawLines", + "DrawText", + "ResetShader", + "SetupShader", + "ResetColorFilter", + "SetupColorFilter", + "ResetShadow", + "SetupShadow" +}; + DisplayList::DisplayList(const DisplayListRenderer& recorder) { initFromDisplayListRenderer(recorder); } @@ -173,14 +206,25 @@ void DisplayList::init() { mPathHeap = NULL; } -void DisplayList::replay(OpenGLRenderer& renderer) { +void DisplayList::replay(OpenGLRenderer& renderer, uint32_t level) { TextContainer text; mReader.rewind(); - int saveCount = renderer.getSaveCount() - 1; +#if DEBUG_DISPLAY_LIST + uint32_t count = (level + 1) * 2; + char indent[count + 1]; + for (uint32_t i = 0; i < count; i++) { + indent[i] = ' '; + } + indent[count] = '\0'; + DISPLAY_LIST_LOGD("%sStart display list (%p)", (char*) indent + 2, this); +#endif + int saveCount = renderer.getSaveCount() - 1; while (!mReader.eof()) { int op = mReader.readInt(); + DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]); + switch (op) { case AcquireContext: { renderer.acquireContext(); @@ -238,7 +282,7 @@ void DisplayList::replay(OpenGLRenderer& renderer) { } break; case DrawDisplayList: { - renderer.drawDisplayList(getDisplayList()); + renderer.drawDisplayList(getDisplayList(), level + 1); } break; case DrawLayer: { @@ -326,6 +370,8 @@ void DisplayList::replay(OpenGLRenderer& renderer) { break; } } + + DISPLAY_LIST_LOGD("%sDone", (char*) indent + 2); } /////////////////////////////////////////////////////////////////////////////// @@ -482,7 +528,7 @@ bool DisplayListRenderer::clipRect(float left, float top, float right, float bot return OpenGLRenderer::clipRect(left, top, right, bottom, op); } -void DisplayListRenderer::drawDisplayList(DisplayList* displayList) { +void DisplayListRenderer::drawDisplayList(DisplayList* displayList, uint32_t level) { addOp(DisplayList::DrawDisplayList); addDisplayList(displayList); } diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index 0822725..cc52309 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -39,6 +39,13 @@ namespace uirenderer { #define MIN_WRITER_SIZE 16384 #define HEAP_BLOCK_SIZE 4096 +// Debug +#if DEBUG_DISPLAY_LIST + #define DISPLAY_LIST_LOGD(...) LOGD(__VA_ARGS__) +#else + #define DISPLAY_LIST_LOGD(...) +#endif + /////////////////////////////////////////////////////////////////////////////// // Helpers /////////////////////////////////////////////////////////////////////////////// @@ -78,8 +85,10 @@ public: DisplayList(const DisplayListRenderer& recorder); ~DisplayList(); + // IMPORTANT: Update the intialization of OP_NAMES in the .cpp file + // when modifying this file enum Op { - AcquireContext, + AcquireContext = 0, ReleaseContext, Save, Restore, @@ -108,12 +117,14 @@ public: ResetColorFilter, SetupColorFilter, ResetShadow, - SetupShadow + SetupShadow, }; + static const char* OP_NAMES[]; + void initFromDisplayListRenderer(const DisplayListRenderer& recorder); - void replay(OpenGLRenderer& renderer); + void replay(OpenGLRenderer& renderer, uint32_t level = 0); private: void init(); @@ -245,7 +256,7 @@ public: bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op); - void drawDisplayList(DisplayList* displayList); + void drawDisplayList(DisplayList* displayList, uint32_t level = 0); void drawLayer(Layer* layer, float x, float y, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint); diff --git a/libs/hwui/OpenGLDebugRenderer.cpp b/libs/hwui/OpenGLDebugRenderer.cpp index f71e5d6..29bcde8 100644 --- a/libs/hwui/OpenGLDebugRenderer.cpp +++ b/libs/hwui/OpenGLDebugRenderer.cpp @@ -48,7 +48,7 @@ int OpenGLDebugRenderer::saveLayer(float left, float top, float right, float bot return OpenGLRenderer::saveLayer(left, top, right, bottom, p, flags); } -void OpenGLDebugRenderer::drawDisplayList(DisplayList* displayList) { +void OpenGLDebugRenderer::drawDisplayList(DisplayList* displayList, uint32_t level) { mPrimitivesCount++; StopWatch w("drawDisplayList"); OpenGLRenderer::drawDisplayList(displayList); diff --git a/libs/hwui/OpenGLDebugRenderer.h b/libs/hwui/OpenGLDebugRenderer.h index 1cef267..aefa7bf 100644 --- a/libs/hwui/OpenGLDebugRenderer.h +++ b/libs/hwui/OpenGLDebugRenderer.h @@ -40,7 +40,7 @@ public: int saveLayer(float left, float top, float right, float bottom, SkPaint* p, int flags); - void drawDisplayList(DisplayList* displayList); + void drawDisplayList(DisplayList* displayList, uint32_t level = 0); void drawLayer(Layer* layer, float x, float y, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint); diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 7f7deec..758bcdc 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -569,6 +569,9 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) { composeLayerRect(layer, rect, true); } + drawColorRect(rect.left, rect.top, rect.right, rect.bottom, 0x7fff0000, + SkXfermode::kSrcOver_Mode, true); + if (fboLayer) { // Detach the texture from the FBO glBindFramebuffer(GL_FRAMEBUFFER, current->fbo); @@ -1024,11 +1027,11 @@ void OpenGLRenderer::finishDrawTexture() { // Drawing /////////////////////////////////////////////////////////////////////////////// -void OpenGLRenderer::drawDisplayList(DisplayList* displayList) { +void OpenGLRenderer::drawDisplayList(DisplayList* displayList, uint32_t level) { // All the usual checks and setup operations (quickReject, setupDraw, etc.) // will be performed by the display list itself if (displayList) { - displayList->replay(*this); + displayList->replay(*this, level); } } diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index da27dac..8cec8f1 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -94,7 +94,7 @@ public: bool quickReject(float left, float top, float right, float bottom); virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op); - virtual void drawDisplayList(DisplayList* displayList); + virtual void drawDisplayList(DisplayList* displayList, uint32_t level = 0); virtual void drawLayer(Layer* layer, float x, float y, SkPaint* paint); virtual void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint); virtual void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint); diff --git a/libs/rs/rsContextHostStub.h b/libs/rs/rsContextHostStub.h index c22647f..8cfb38b 100644 --- a/libs/rs/rsContextHostStub.h +++ b/libs/rs/rsContextHostStub.h @@ -119,11 +119,12 @@ public: mutable const ObjectBase * mObjHead; bool ext_OES_texture_npot() const {return mGL.OES_texture_npot;} - bool ext_GL_NV_texture_npot_2D_mipmap() const {return false;} - float ext_texture_max_aniso() const {return 1.0f;} + bool ext_GL_NV_texture_npot_2D_mipmap() const {return mGL.GL_NV_texture_npot_2D_mipmap;} + float ext_texture_max_aniso() const {return mGL.EXT_texture_max_aniso; } uint32_t getMaxFragmentTextures() const {return mGL.mMaxFragmentTextureImageUnits;} uint32_t getMaxFragmentUniformVectors() const {return mGL.mMaxFragmentUniformVectors;} uint32_t getMaxVertexUniformVectors() const {return mGL.mMaxVertexUniformVectors;} + uint32_t getMaxVertexAttributes() const {return mGL.mMaxVertexAttribs;} protected: @@ -147,6 +148,8 @@ protected: int32_t mMaxVertexTextureUnits; bool OES_texture_npot; + bool GL_NV_texture_npot_2D_mipmap; + float EXT_texture_max_aniso; } mGL; }; diff --git a/libs/surfaceflinger_client/Android.mk b/libs/surfaceflinger_client/Android.mk index ce3c71a..4a0faf0 100644 --- a/libs/surfaceflinger_client/Android.mk +++ b/libs/surfaceflinger_client/Android.mk @@ -5,6 +5,7 @@ LOCAL_SRC_FILES:= \ ISurfaceComposer.cpp \ ISurface.cpp \ ISurfaceComposerClient.cpp \ + IGraphicBufferAlloc.cpp \ LayerState.cpp \ SharedBufferStack.cpp \ Surface.cpp \ diff --git a/libs/surfaceflinger_client/IGraphicBufferAlloc.cpp b/libs/surfaceflinger_client/IGraphicBufferAlloc.cpp new file mode 100644 index 0000000..e05da72 --- /dev/null +++ b/libs/surfaceflinger_client/IGraphicBufferAlloc.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tag as surfaceflinger +#define LOG_TAG "SurfaceFlinger" + +#include <stdint.h> +#include <sys/types.h> + +#include <binder/Parcel.h> + +#include <ui/GraphicBuffer.h> + +#include <surfaceflinger/IGraphicBufferAlloc.h> + +// --------------------------------------------------------------------------- + +namespace android { + +enum { + CREATE_GRAPHIC_BUFFER = IBinder::FIRST_CALL_TRANSACTION, + FREE_ALL_GRAPHIC_BUFFERS_EXCEPT, +}; + +class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc> +{ +public: + BpGraphicBufferAlloc(const sp<IBinder>& impl) + : BpInterface<IGraphicBufferAlloc>(impl) + { + } + + virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, + PixelFormat format, uint32_t usage) { + Parcel data, reply; + data.writeInterfaceToken( + IGraphicBufferAlloc::getInterfaceDescriptor()); + data.writeInt32(w); + data.writeInt32(h); + data.writeInt32(format); + data.writeInt32(usage); + remote()->transact(CREATE_GRAPHIC_BUFFER, data, &reply); + sp<GraphicBuffer> graphicBuffer; + bool nonNull = (bool)reply.readInt32(); + if (nonNull) { + graphicBuffer = new GraphicBuffer(); + reply.read(*graphicBuffer); + } + return graphicBuffer; + } + + virtual void freeAllGraphicBuffersExcept(int bufIdx) { + Parcel data, reply; + data.writeInterfaceToken( + IGraphicBufferAlloc::getInterfaceDescriptor()); + data.writeInt32(bufIdx); + remote()->transact(FREE_ALL_GRAPHIC_BUFFERS_EXCEPT, data, &reply); + } +}; + +IMPLEMENT_META_INTERFACE(GraphicBufferAlloc, "android.ui.IGraphicBufferAlloc"); + +// ---------------------------------------------------------------------- + +status_t BnGraphicBufferAlloc::onTransact( + uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) +{ + // codes that don't require permission check + + switch(code) { + case CREATE_GRAPHIC_BUFFER: { + CHECK_INTERFACE(IGraphicBufferAlloc, data, reply); + uint32_t w = data.readInt32(); + uint32_t h = data.readInt32(); + PixelFormat format = data.readInt32(); + uint32_t usage = data.readInt32(); + sp<GraphicBuffer> result(createGraphicBuffer(w, h, format, usage)); + reply->writeInt32(result != 0); + if (result != 0) { + reply->write(*result); + } + return NO_ERROR; + } break; + case FREE_ALL_GRAPHIC_BUFFERS_EXCEPT: { + CHECK_INTERFACE(IGraphicBufferAlloc, data, reply); + int bufIdx = data.readInt32(); + freeAllGraphicBuffersExcept(bufIdx); + return NO_ERROR; + } break; + default: + return BBinder::onTransact(code, data, reply, flags); + } +} + +}; // namespace android diff --git a/libs/surfaceflinger_client/ISurfaceComposer.cpp b/libs/surfaceflinger_client/ISurfaceComposer.cpp index a42b49d..2216824 100644 --- a/libs/surfaceflinger_client/ISurfaceComposer.cpp +++ b/libs/surfaceflinger_client/ISurfaceComposer.cpp @@ -26,7 +26,6 @@ #include <binder/IServiceManager.h> #include <ui/DisplayInfo.h> -#include <ui/GraphicBuffer.h> #include <surfaceflinger/ISurfaceComposer.h> @@ -65,6 +64,15 @@ public: return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); } + virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() + { + uint32_t n; + Parcel data, reply; + data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); + remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER_ALLOC, data, &reply); + return interface_cast<IGraphicBufferAlloc>(reply.readStrongBinder()); + } + virtual sp<IMemoryHeap> getCblk() const { Parcel data, reply; @@ -170,25 +178,6 @@ public: data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); remote()->transact(BnSurfaceComposer::SIGNAL, data, &reply, IBinder::FLAG_ONEWAY); } - - virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, - PixelFormat format, uint32_t usage) const { - Parcel data, reply; - data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); - data.writeInt32(w); - data.writeInt32(h); - data.writeInt32(format); - data.writeInt32(usage); - remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER, data, - &reply); - sp<GraphicBuffer> graphicBuffer; - bool nonNull = (bool)reply.readInt32(); - if (nonNull) { - graphicBuffer = new GraphicBuffer(); - reply.read(*graphicBuffer); - } - return graphicBuffer; - } }; IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); @@ -209,6 +198,11 @@ status_t BnSurfaceComposer::onTransact( sp<IBinder> b = createClientConnection()->asBinder(); reply->writeStrongBinder(b); } break; + case CREATE_GRAPHIC_BUFFER_ALLOC: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); + sp<IBinder> b = createGraphicBufferAlloc()->asBinder(); + reply->writeStrongBinder(b); + } break; case OPEN_GLOBAL_TRANSACTION: { CHECK_INTERFACE(ISurfaceComposer, data, reply); openGlobalTransaction(); @@ -267,18 +261,6 @@ status_t BnSurfaceComposer::onTransact( reply->writeInt32(f); reply->writeInt32(res); } break; - case CREATE_GRAPHIC_BUFFER: { - CHECK_INTERFACE(ISurfaceComposer, data, reply); - uint32_t w = data.readInt32(); - uint32_t h = data.readInt32(); - PixelFormat format = data.readInt32(); - uint32_t usage = data.readInt32(); - sp<GraphicBuffer> result(createGraphicBuffer(w, h, format, usage)); - reply->writeInt32(result != 0); - if (result != 0) { - reply->write(*result); - } - } break; case TURN_ELECTRON_BEAM_OFF: { CHECK_INTERFACE(ISurfaceComposer, data, reply); int32_t mode = data.readInt32(); diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 243fa07..a6037aa 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -122,8 +122,10 @@ import android.media.IAudioService; import android.media.AudioManager; import java.io.File; +import java.io.FileDescriptor; import java.io.FileReader; import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; /** @@ -2808,4 +2810,70 @@ public class PhoneWindowManager implements WindowManagerPolicy { // disable key repeat when screen is off return mScreenOn; } + + public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args) { + pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); + pw.print(" mSystemRead="); pw.println(mSystemReady); + pw.print(prefix); pw.print("mLidOpen="); pw.print(mLidOpen); + pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); + pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); + pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); + pw.print(" mDockMode="); pw.print(mDockMode); + pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); + pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); + pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); + pw.print(" mUserRotation="); pw.print(mUserRotation); + pw.print("mAllowAllRotations="); pw.println(mAllowAllRotations); + pw.print(prefix); pw.print("mAccelerometerDefault="); pw.print(mAccelerometerDefault); + pw.print(" mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); + pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); + pw.print(mCarDockEnablesAccelerometer); + pw.print(" mDeskDockEnablesAccelerometer="); + pw.println(mDeskDockEnablesAccelerometer); + pw.print(prefix); pw.print("mLidKeyboardAccessibility="); + pw.print(mLidKeyboardAccessibility); + pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); + pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior); + pw.print(prefix); pw.print("mScreenOn="); pw.print(mScreenOn); + pw.print(" mOrientationSensorEnabled="); pw.print(mOrientationSensorEnabled); + pw.print(" mHasSoftInput="); pw.println(mHasSoftInput); + pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); + pw.print(","); pw.print(mUnrestrictedScreenTop); + pw.print(") "); pw.print(mUnrestrictedScreenWidth); + pw.print("x"); pw.println(mUnrestrictedScreenHeight); + pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); + pw.print(","); pw.print(mRestrictedScreenTop); + pw.print(") "); pw.print(mRestrictedScreenWidth); + pw.print("x"); pw.println(mRestrictedScreenHeight); + pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); + pw.print(","); pw.print(mCurTop); + pw.print(")-("); pw.print(mCurRight); + pw.print(","); pw.print(mCurBottom); pw.println(")"); + pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); + pw.print(","); pw.print(mContentTop); + pw.print(")-("); pw.print(mContentRight); + pw.print(","); pw.print(mContentBottom); pw.println(")"); + pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); + pw.print(","); pw.print(mDockTop); + pw.print(")-("); pw.print(mDockRight); + pw.print(","); pw.print(mDockBottom); pw.println(")"); + pw.print(prefix); pw.print("mDockLayer="); pw.println(mDockLayer); + pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); + pw.println(mTopFullscreenOpaqueWindowState); + pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); + pw.print(" mForceStatusBar="); pw.print(mForceStatusBar); + pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); + pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); + pw.print(" mHomePressed="); pw.println(mHomePressed); + pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); + pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); + pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); + pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); + pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); + pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); + pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); + pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); + pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); + pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); + } } diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index b196f74..26060e6 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -7453,6 +7453,10 @@ class PackageManagerService extends IPackageManager.Stub { static class PackageSignatures { private Signature[] mSignatures; + PackageSignatures(PackageSignatures orig) { + mSignatures = orig.mSignatures.clone(); + } + PackageSignatures(Signature[] sigs) { assignSignatures(sigs); } @@ -7788,6 +7792,12 @@ class PackageManagerService extends IPackageManager.Stub { setFlags(pkgFlags); } + GrantedPermissions(GrantedPermissions base) { + pkgFlags = base.pkgFlags; + grantedPermissions = (HashSet<String>) base.grantedPermissions.clone(); + gids = base.gids.clone(); + } + void setFlags(int pkgFlags) { this.pkgFlags = pkgFlags & ( ApplicationInfo.FLAG_SYSTEM | @@ -7815,7 +7825,7 @@ class PackageManagerService extends IPackageManager.Stub { int versionCode; boolean uidError; - + PackageSignatures signatures = new PackageSignatures(); boolean permissionsFixed; @@ -7841,6 +7851,44 @@ class PackageManagerService extends IPackageManager.Stub { init(codePath, resourcePath, nativeLibraryPathString, pVersionCode); } + /** + * New instance of PackageSetting with one-level-deep cloning. + */ + PackageSettingBase(PackageSettingBase base) { + super(base); + + name = base.name; + realName = base.realName; + codePath = base.codePath; + codePathString = base.codePathString; + resourcePath = base.resourcePath; + resourcePathString = base.resourcePathString; + nativeLibraryPathString = base.nativeLibraryPathString; + obbPathString = base.obbPathString; + timeStamp = base.timeStamp; + firstInstallTime = base.firstInstallTime; + lastUpdateTime = base.lastUpdateTime; + versionCode = base.versionCode; + + uidError = base.uidError; + + signatures = new PackageSignatures(base.signatures); + + permissionsFixed = base.permissionsFixed; + haveGids = base.haveGids; + + disabledComponents = (HashSet<String>) base.disabledComponents.clone(); + + enabledComponents = (HashSet<String>) base.enabledComponents.clone(); + + enabled = base.enabled; + installStatus = base.installStatus; + + origPackage = base.origPackage; + + installerPackageName = base.installerPackageName; + } + void init(File codePath, File resourcePath, String nativeLibraryPathString, int pVersionCode) { this.codePath = codePath; @@ -7871,6 +7919,9 @@ class PackageManagerService extends IPackageManager.Stub { timeStamp = newStamp; } + /** + * Make a shallow copy of this package settings. + */ public void copyFrom(PackageSettingBase base) { grantedPermissions = base.grantedPermissions; gids = base.gids; @@ -7930,18 +7981,16 @@ class PackageManagerService extends IPackageManager.Stub { pkgFlags); } + /** + * New instance of PackageSetting replicating the original settings. + * Note that it keeps the same PackageParser.Package instance. + */ PackageSetting(PackageSetting orig) { - super(orig.name, orig.realName, orig.codePath, orig.resourcePath, - orig.nativeLibraryPathString, orig.versionCode, orig.pkgFlags); - copyFrom(orig); - } - - public void copyFrom(PackageSetting base) { - super.copyFrom((PackageSettingBase) base); + super(orig); - userId = base.userId; - sharedUser = base.sharedUser; - pkg = base.pkg; + userId = orig.userId; + pkg = orig.pkg; + sharedUser = orig.sharedUser; } @Override @@ -8173,7 +8222,7 @@ class PackageManagerService extends IPackageManager.Stub { // a little trick... when we install the new package, we don't // want to modify the existing PackageSetting for the built-in // version. so at this point we need a new PackageSetting that - // is okay to much with. + // is okay to muck with. PackageSetting newp = new PackageSetting(p); replacePackageLP(name, newp); return true; diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 1e3b102..182e898 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -149,6 +149,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdog.Monitor { static final String TAG = "WindowManager"; static final boolean DEBUG = false; + static final boolean DEBUG_ADD_REMOVE = false; static final boolean DEBUG_FOCUS = false; static final boolean DEBUG_ANIM = false; static final boolean DEBUG_LAYOUT = false; @@ -158,6 +159,7 @@ public class WindowManagerService extends IWindowManager.Stub static final boolean DEBUG_INPUT_METHOD = false; static final boolean DEBUG_VISIBILITY = false; static final boolean DEBUG_WINDOW_MOVEMENT = false; + static final boolean DEBUG_TOKEN_MOVEMENT = false; static final boolean DEBUG_ORIENTATION = false; static final boolean DEBUG_CONFIGURATION = false; static final boolean DEBUG_APP_TRANSITIONS = false; @@ -296,12 +298,6 @@ public class WindowManagerService extends IWindowManager.Stub new HashMap<IBinder, WindowToken>(); /** - * The same tokens as mTokenMap, stored in a list for efficient iteration - * over them. - */ - final ArrayList<WindowToken> mTokenList = new ArrayList<WindowToken>(); - - /** * Window tokens that are in the process of exiting, but still * on screen for animations. */ @@ -310,7 +306,7 @@ public class WindowManagerService extends IWindowManager.Stub /** * Z-ordered (bottom-most first) list of all application tokens, for * controlling the ordering of windows in different applications. This - * contains WindowToken objects. + * contains AppWindowToken objects. */ final ArrayList<AppWindowToken> mAppTokens = new ArrayList<AppWindowToken>(); @@ -344,6 +340,11 @@ public class WindowManagerService extends IWindowManager.Stub final ArrayList<WindowState> mPendingRemove = new ArrayList<WindowState>(); /** + * Used when processing mPendingRemove to avoid working on the original array. + */ + WindowState[] mPendingRemoveTmp = new WindowState[20]; + + /** * Windows whose surface should be destroyed. */ final ArrayList<WindowState> mDestroySurface = new ArrayList<WindowState>(); @@ -360,6 +361,12 @@ public class WindowManagerService extends IWindowManager.Stub */ ArrayList<WindowState> mForceRemoves; + /** + * Used when rebuilding window list to keep track of windows that have + * been removed. + */ + WindowState[] mRebuildTmp = new WindowState[20]; + IInputMethodManager mInputMethodManager; SurfaceSession mFxSession; @@ -505,6 +512,10 @@ public class WindowManagerService extends IWindowManager.Stub ArrayList<WindowState> mNotifiedWindows; boolean mDragInProgress; + boolean mPerformDeferredRotation; + int mRotation; + int mAnimFlags; + private final Rect tmpRect = new Rect(); DragState(IBinder token, Surface surface, int flags, IBinder localWin) { @@ -526,6 +537,7 @@ public class WindowManagerService extends IWindowManager.Stub mData = null; mThumbOffsetX = mThumbOffsetY = 0; mNotifiedWindows = null; + mPerformDeferredRotation = false; } void register() { @@ -666,9 +678,25 @@ public class WindowManagerService extends IWindowManager.Stub mDragState.unregister(); mInputMonitor.updateInputWindowsLw(); + // Retain the parameters of any deferred rotation operation so + // that we can perform it after the reset / unref of the drag state + final boolean performRotation = mPerformDeferredRotation; + final int rotation = mRotation; + final int animFlags = mAnimFlags; + // free our resources and drop all the object references mDragState.reset(); mDragState = null; + + // Now that we've officially ended the drag, execute any + // deferred rotation + if (performRotation) { + if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-drag rotation"); + boolean changed = setRotationUncheckedLocked(rotation, animFlags); + if (changed) { + sendNewConfiguration(); + } + } } void notifyMoveLw(float x, float y) { @@ -812,6 +840,12 @@ public class WindowManagerService extends IWindowManager.Stub return touchedWin; } + + void setDeferredRotation(int rotation, int animFlags) { + mRotation = rotation; + mAnimFlags = animFlags; + mPerformDeferredRotation = true; + } } DragState mDragState = null; @@ -1062,7 +1096,7 @@ public class WindowManagerService extends IWindowManager.Stub private void placeWindowAfter(WindowState pos, WindowState window) { final int i = mWindows.indexOf(pos); - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( TAG, "Adding window " + window + " at " + (i+1) + " of " + mWindows.size() + " (after " + pos + ")"); mWindows.add(i+1, window); @@ -1071,7 +1105,7 @@ public class WindowManagerService extends IWindowManager.Stub private void placeWindowBefore(WindowState pos, WindowState window) { final int i = mWindows.indexOf(pos); - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( TAG, "Adding window " + window + " at " + i + " of " + mWindows.size() + " (before " + pos + ")"); mWindows.add(i, window); @@ -1129,9 +1163,10 @@ public class WindowManagerService extends IWindowManager.Stub //apptoken note that the window could be a floating window //that was created later or a window at the top of the list of //windows associated with this token. - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( - TAG, "Adding window " + win + " at " - + (newIdx+1) + " of " + N); + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) { + Slog.v(TAG, "Adding window " + win + " at " + + (newIdx+1) + " of " + N); + } localmWindows.add(newIdx+1, win); mWindowsChanged = true; } @@ -1210,9 +1245,10 @@ public class WindowManagerService extends IWindowManager.Stub break; } } - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( - TAG, "Adding window " + win + " at " - + i + " of " + N); + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) { + Slog.v(TAG, "Adding window " + win + " at " + + i + " of " + N); + } localmWindows.add(i, win); mWindowsChanged = true; } @@ -1228,13 +1264,14 @@ public class WindowManagerService extends IWindowManager.Stub } } if (i < 0) i = 0; - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( TAG, "Adding window " + win + " at " + i + " of " + N); localmWindows.add(i, win); mWindowsChanged = true; } if (addToToken) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + win + " to " + token); token.windows.add(tokenWindowsPos, win); } @@ -1257,6 +1294,7 @@ public class WindowManagerService extends IWindowManager.Stub // in the same sublayer. if (wSublayer >= sublayer) { if (addToToken) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + win + " to " + token); token.windows.add(i, win); } placeWindowBefore( @@ -1268,6 +1306,7 @@ public class WindowManagerService extends IWindowManager.Stub // in the same sublayer. if (wSublayer > sublayer) { if (addToToken) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + win + " to " + token); token.windows.add(i, win); } placeWindowBefore(w, win); @@ -1277,6 +1316,7 @@ public class WindowManagerService extends IWindowManager.Stub } if (i >= NA) { if (addToToken) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + win + " to " + token); token.windows.add(win); } if (sublayer < 0) { @@ -1451,7 +1491,7 @@ public class WindowManagerService extends IWindowManager.Stub int pos = findDesiredInputMethodWindowIndexLocked(true); if (pos >= 0) { win.mTargetAppToken = mInputMethodTarget.mAppToken; - if (DEBUG_WINDOW_MOVEMENT) Slog.v( + if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( TAG, "Adding input method window " + win + " at " + pos); mWindows.add(pos, win); mWindowsChanged = true; @@ -2001,9 +2041,10 @@ public class WindowManagerService extends IWindowManager.Stub } // Now stick it in. - if (DEBUG_WALLPAPER || DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, - "Moving wallpaper " + wallpaper - + " from " + oldIndex + " to " + foundI); + if (DEBUG_WALLPAPER || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) { + Slog.v(TAG, "Moving wallpaper " + wallpaper + + " from " + oldIndex + " to " + foundI); + } localmWindows.add(foundI, wallpaper); mWindowsChanged = true; @@ -2322,7 +2363,6 @@ public class WindowManagerService extends IWindowManager.Stub if (addToken) { mTokenMap.put(attrs.token, token); - mTokenList.add(token); } win.attach(); mWindowMap.put(client.asBinder(), win); @@ -2485,6 +2525,18 @@ public class WindowManagerService extends IWindowManager.Stub } private void removeWindowInnerLocked(Session session, WindowState win) { + if (win.mRemoved) { + // Nothing to do. + return; + } + + for (int i=win.mChildWindows.size()-1; i>=0; i--) { + WindowState cwin = win.mChildWindows.get(i); + Slog.w(TAG, "Force-removing child win " + cwin + " from container " + + win); + removeWindowInnerLocked(cwin.mSession, cwin); + } + win.mRemoved = true; if (mInputMethodTarget == win) { @@ -2500,8 +2552,10 @@ public class WindowManagerService extends IWindowManager.Stub mPolicy.removeWindowLw(win); win.removeLocked(); + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "removeWindowInnerLocked: " + win); mWindowMap.remove(win.mClient.asBinder()); mWindows.remove(win); + mPendingRemove.remove(win); mWindowsChanged = true; if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Final remove of window: " + win); @@ -2513,6 +2567,7 @@ public class WindowManagerService extends IWindowManager.Stub final WindowToken token = win.mToken; final AppWindowToken atoken = win.mAppToken; + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + win + " from " + token); token.windows.remove(win); if (atoken != null) { atoken.allAppWindows.remove(win); @@ -2523,7 +2578,6 @@ public class WindowManagerService extends IWindowManager.Stub if (token.windows.size() == 0) { if (!token.explicit) { mTokenMap.remove(token.token); - mTokenList.remove(token); } else if (atoken != null) { atoken.firstWindowDrawn = false; } @@ -3286,7 +3340,6 @@ public class WindowManagerService extends IWindowManager.Stub } wtoken = new WindowToken(token, type, true); mTokenMap.put(token, wtoken); - mTokenList.add(wtoken); if (type == TYPE_WALLPAPER) { mWallpaperTokens.add(wtoken); } @@ -3302,7 +3355,6 @@ public class WindowManagerService extends IWindowManager.Stub final long origId = Binder.clearCallingIdentity(); synchronized(mWindowMap) { WindowToken wtoken = mTokenMap.remove(token); - mTokenList.remove(wtoken); if (wtoken != null) { boolean delayed = false; if (!wtoken.hidden) { @@ -3378,10 +3430,9 @@ public class WindowManagerService extends IWindowManager.Stub wtoken.groupId = groupId; wtoken.appFullscreen = fullscreen; wtoken.requestedOrientation = requestedOrientation; + if (DEBUG_TOKEN_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "addAppToken: " + wtoken); mAppTokens.add(addPos, wtoken); - if (localLOGV) Slog.v(TAG, "Adding new app token: " + wtoken); mTokenMap.put(token.asBinder(), wtoken); - mTokenList.add(wtoken); // Application tokens start out hidden. wtoken.hidden = true; @@ -3792,10 +3843,12 @@ public class WindowManagerService extends IWindowManager.Stub startingWindow.mToken = wtoken; startingWindow.mRootToken = wtoken; startingWindow.mAppToken = wtoken; - if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, + if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing starting window: " + startingWindow); mWindows.remove(startingWindow); mWindowsChanged = true; + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing starting " + startingWindow + + " from " + ttoken); ttoken.windows.remove(startingWindow); ttoken.allAppWindows.remove(startingWindow); addWindowToListInOrderLocked(startingWindow, true); @@ -4210,7 +4263,6 @@ public class WindowManagerService extends IWindowManager.Stub final long origId = Binder.clearCallingIdentity(); synchronized(mWindowMap) { WindowToken basewtoken = mTokenMap.remove(token); - mTokenList.remove(basewtoken); if (basewtoken != null && (wtoken=basewtoken.appWindowToken) != null) { if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Removing app token: " + wtoken); delayed = setTokenVisibilityLocked(wtoken, null, false, WindowManagerPolicy.TRANSIT_UNSET, true); @@ -4230,6 +4282,8 @@ public class WindowManagerService extends IWindowManager.Stub + " animating=" + wtoken.animating); if (delayed) { // set the token aside because it has an active animation to be finished + if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "removeAppToken make exiting: " + wtoken); mExitingAppTokens.add(wtoken); } else { // Make sure there is no animation running on this token, @@ -4238,6 +4292,8 @@ public class WindowManagerService extends IWindowManager.Stub wtoken.animation = null; wtoken.animating = false; } + if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "removeAppToken: " + wtoken); mAppTokens.remove(wtoken); wtoken.removed = true; if (wtoken.startingData != null) { @@ -4364,18 +4420,21 @@ public class WindowManagerService extends IWindowManager.Stub if (!added && cwin.mSubLayer >= 0) { if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding child window at " + index + ": " + cwin); + win.mRebuilding = false; mWindows.add(index, win); index++; added = true; } if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding window at " + index + ": " + cwin); + cwin.mRebuilding = false; mWindows.add(index, cwin); index++; } if (!added) { if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding window at " + index + ": " + win); + win.mRebuilding = false; mWindows.add(index, win); index++; } @@ -4401,6 +4460,9 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_REORDER) Slog.v(TAG, "Initial app tokens:"); if (DEBUG_REORDER) dumpAppTokensLocked(); final AppWindowToken wtoken = findAppWindowToken(token); + if (DEBUG_TOKEN_MOVEMENT || DEBUG_REORDER) Slog.v(TAG, + "Start moving token " + wtoken + " initially at " + + mAppTokens.indexOf(wtoken)); if (wtoken == null || !mAppTokens.remove(wtoken)) { Slog.w(TAG, "Attempting to reorder token that doesn't exist: " + token + " (" + wtoken + ")"); @@ -4408,6 +4470,7 @@ public class WindowManagerService extends IWindowManager.Stub } mAppTokens.add(index, wtoken); if (DEBUG_REORDER) Slog.v(TAG, "Moved " + token + " to " + index + ":"); + else if (DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, "Moved " + token + " to " + index); if (DEBUG_REORDER) dumpAppTokensLocked(); final long origId = Binder.clearCallingIdentity(); @@ -4435,6 +4498,8 @@ public class WindowManagerService extends IWindowManager.Stub for (int i=0; i<N; i++) { IBinder token = tokens.get(i); final AppWindowToken wtoken = findAppWindowToken(token); + if (DEBUG_REORDER || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "Temporarily removing " + wtoken + " from " + mAppTokens.indexOf(wtoken)); if (!mAppTokens.remove(wtoken)) { Slog.w(TAG, "Attempting to reorder token that doesn't exist: " + token + " (" + wtoken + ")"); @@ -4508,6 +4573,8 @@ public class WindowManagerService extends IWindowManager.Stub for (int i=0; i<N; i++) { AppWindowToken wt = findAppWindowToken(tokens.get(i)); if (wt != null) { + if (DEBUG_TOKEN_MOVEMENT || DEBUG_REORDER) Slog.v(TAG, + "Adding next to top: " + wt); mAppTokens.add(wt); if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { mToTopApps.remove(wt); @@ -4540,6 +4607,8 @@ public class WindowManagerService extends IWindowManager.Stub for (int i=0; i<N; i++) { AppWindowToken wt = findAppWindowToken(tokens.get(i)); if (wt != null) { + if (DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "Adding next to bottom: " + wt + " at " + pos); mAppTokens.add(pos, wt); if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { mToTopApps.remove(wt); @@ -5076,6 +5145,14 @@ public class WindowManagerService extends IWindowManager.Stub * MUST CALL setNewConfiguration() TO UNFREEZE THE SCREEN. */ public boolean setRotationUncheckedLocked(int rotation, int animFlags) { + if (mDragState != null) { + // Potential rotation during a drag. Don't do the rotation now, but make + // a note to perform the rotation later. + if (DEBUG_ORIENTATION) Slog.v(TAG, "Deferring rotation during drag"); + mDragState.setDeferredRotation(rotation, animFlags); + return false; + } + boolean changed; if (rotation == WindowManagerPolicy.USE_LAST_ROTATION) { rotation = mRequestedRotation; @@ -6496,24 +6573,28 @@ public class WindowManagerService extends IWindowManager.Stub } synchronized (mWindowMap) { - if (mDragState.mToken != token) { - Slog.w(TAG, "Invalid drop-result claim by " + window); - throw new IllegalStateException("reportDropResult() by non-recipient"); - } + long ident = Binder.clearCallingIdentity(); + try { + if (mDragState.mToken != token) { + Slog.w(TAG, "Invalid drop-result claim by " + window); + throw new IllegalStateException("reportDropResult() by non-recipient"); + } - // The right window has responded, even if it's no longer around, - // so be sure to halt the timeout even if the later WindowState - // lookup fails. - mH.removeMessages(H.DRAG_END_TIMEOUT, window.asBinder()); + // The right window has responded, even if it's no longer around, + // so be sure to halt the timeout even if the later WindowState + // lookup fails. + mH.removeMessages(H.DRAG_END_TIMEOUT, window.asBinder()); + WindowState callingWin = windowForClientLocked(null, window, false); + if (callingWin == null) { + Slog.w(TAG, "Bad result-reporting window " + window); + return; // !!! TODO: throw here? + } - WindowState callingWin = windowForClientLocked(null, window, false); - if (callingWin == null) { - Slog.w(TAG, "Bad result-reporting window " + window); - return; // !!! TODO: throw here? + mDragState.mDragResult = consumed; + mDragState.endDragLw(); + } finally { + Binder.restoreCallingIdentity(ident); } - - mDragState.mDragResult = consumed; - mDragState.endDragLw(); } } @@ -6801,6 +6882,10 @@ public class WindowManagerService extends IWindowManager.Stub // Is this window now (or just being) removed? boolean mRemoved; + // Temp for keeping track of windows that have been removed when + // rebuilding window list. + boolean mRebuilding; + // For debugging, this is the last information given to the surface flinger. boolean mSurfaceShown; int mSurfaceX, mSurfaceY, mSurfaceW, mSurfaceH; @@ -6853,6 +6938,7 @@ public class WindowManagerService extends IWindowManager.Stub + TYPE_LAYER_OFFSET; mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type); mAttachedWindow = attachedWindow; + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow); mAttachedWindow.mChildWindows.add(this); mLayoutAttached = mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; @@ -7858,6 +7944,7 @@ public class WindowManagerService extends IWindowManager.Stub disposeInputChannel(); if (mAttachedWindow != null) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mAttachedWindow); mAttachedWindow.mChildWindows.remove(this); } destroySurfaceLocked(); @@ -9107,12 +9194,18 @@ public class WindowManagerService extends IWindowManager.Stub int lastWallpaper = -1; int numRemoved = 0; + if (mRebuildTmp.length < NW) { + mRebuildTmp = new WindowState[NW+10]; + } + // First remove all existing app windows. i=0; while (i < NW) { WindowState w = mWindows.get(i); if (w.mAppToken != null) { WindowState win = mWindows.remove(i); + win.mRebuilding = true; + mRebuildTmp[numRemoved] = win; mWindowsChanged = true; if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Rebuild removing window: " + win); @@ -9150,6 +9243,21 @@ public class WindowManagerService extends IWindowManager.Stub if (i != numRemoved) { Slog.w(TAG, "Rebuild removed " + numRemoved + " windows but added " + i); + for (i=0; i<numRemoved; i++) { + WindowState ws = mRebuildTmp[i]; + if (ws.mRebuilding) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + ws.dump(pw, ""); + pw.flush(); + Slog.w(TAG, "This window was lost: " + ws); + Slog.w(TAG, sw.toString()); + } + } + Slog.w(TAG, "Current app token list:"); + dumpAppTokensLocked(); + Slog.w(TAG, "Final window list:"); + dumpWindowsLocked(); } } @@ -9222,7 +9330,7 @@ public class WindowManagerService extends IWindowManager.Stub try { if (mForceRemoves != null) { recoveringMemory = true; - // Wait a little it for things to settle down, and off we go. + // Wait a little bit for things to settle down, and off we go. for (int i=0; i<mForceRemoves.size(); i++) { WindowState ws = mForceRemoves.get(i); Slog.i(TAG, "Force removing: " + ws); @@ -9245,14 +9353,17 @@ public class WindowManagerService extends IWindowManager.Stub try { performLayoutAndPlaceSurfacesLockedInner(recoveringMemory); - int i = mPendingRemove.size()-1; - if (i >= 0) { - while (i >= 0) { - WindowState w = mPendingRemove.get(i); - removeWindowInnerLocked(w.mSession, w); - i--; + int N = mPendingRemove.size(); + if (N > 0) { + if (mPendingRemoveTmp.length < N) { + mPendingRemoveTmp = new WindowState[N+10]; } + mPendingRemove.toArray(mPendingRemoveTmp); mPendingRemove.clear(); + for (int i=0; i<N; i++) { + WindowState w = mPendingRemoveTmp[i]; + removeWindowInnerLocked(w.mSession, w); + } mInLayout = false; assignLayersLocked(); @@ -9696,12 +9807,9 @@ public class WindowManagerService extends IWindowManager.Stub if (tokenMayBeDrawn) { // See if any windows have been drawn, so they (and others // associated with them) can now be shown. - final int NT = mTokenList.size(); + final int NT = mAppTokens.size(); for (i=0; i<NT; i++) { - AppWindowToken wtoken = mTokenList.get(i).appWindowToken; - if (wtoken == null) { - continue; - } + AppWindowToken wtoken = mAppTokens.get(i); if (wtoken.freezingScreen) { int numInteresting = wtoken.numInterestingWindows; if (numInteresting > 0 && wtoken.numDrawnWindows >= numInteresting) { @@ -10603,6 +10711,8 @@ public class WindowManagerService extends IWindowManager.Stub // soon as their animations are complete token.animation = null; token.animating = false; + if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "performLayout: App token exiting now removed" + token); mAppTokens.remove(token); mExitingAppTokens.remove(i); } @@ -11312,14 +11422,6 @@ public class WindowManagerService extends IWindowManager.Stub token.dump(pw, " "); } } - if (mTokenList.size() > 0) { - pw.println(" "); - pw.println(" Window token list:"); - for (int i=0; i<mTokenList.size(); i++) { - pw.print(" #"); pw.print(i); pw.print(": "); - pw.println(mTokenList.get(i)); - } - } if (mWallpaperTokens.size() > 0) { pw.println(" "); pw.println(" Wallpaper tokens:"); @@ -11443,6 +11545,8 @@ public class WindowManagerService extends IWindowManager.Stub } else { pw.println(" NO DISPLAY"); } + pw.println(" Policy:"); + mPolicy.dump(" ", fd, pw, args); } } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index c982ea5..967ff1a 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -144,6 +144,11 @@ sp<ISurfaceComposerClient> SurfaceFlinger::createClientConnection() return bclient; } +sp<IGraphicBufferAlloc> SurfaceFlinger::createGraphicBufferAlloc() +{ + sp<GraphicBufferAlloc> gba(new GraphicBufferAlloc()); + return gba; +} const GraphicPlane& SurfaceFlinger::graphicPlane(int dpy) const { @@ -2267,25 +2272,6 @@ sp<Layer> SurfaceFlinger::getLayer(const sp<ISurface>& sur) const // --------------------------------------------------------------------------- -sp<GraphicBuffer> SurfaceFlinger::createGraphicBuffer(uint32_t w, uint32_t h, - PixelFormat format, uint32_t usage) const { - // XXX: HACK HACK HACK!!! This should NOT be static, but it is to fix a - // race between SurfaceFlinger unref'ing the buffer and the client ref'ing - // it. - static sp<GraphicBuffer> graphicBuffer(new GraphicBuffer(w, h, format, usage)); - status_t err = graphicBuffer->initCheck(); - if (err != 0) { - LOGE("createGraphicBuffer: init check failed: %d", err); - return 0; - } else if (graphicBuffer->handle == 0) { - LOGE("createGraphicBuffer: unable to create GraphicBuffer"); - return 0; - } - return graphicBuffer; -} - -// --------------------------------------------------------------------------- - Client::Client(const sp<SurfaceFlinger>& flinger) : mFlinger(flinger), mNameGenerator(1) { @@ -2465,6 +2451,39 @@ status_t UserClient::setState(int32_t count, const layer_state_t* states) { // --------------------------------------------------------------------------- +GraphicBufferAlloc::GraphicBufferAlloc() {} + +GraphicBufferAlloc::~GraphicBufferAlloc() {} + +sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h, + PixelFormat format, uint32_t usage) { + sp<GraphicBuffer> graphicBuffer(new GraphicBuffer(w, h, format, usage)); + status_t err = graphicBuffer->initCheck(); + if (err != 0) { + LOGE("createGraphicBuffer: init check failed: %d", err); + return 0; + } else if (graphicBuffer->handle == 0) { + LOGE("createGraphicBuffer: unable to create GraphicBuffer"); + return 0; + } + Mutex::Autolock _l(mLock); + mBuffers.add(graphicBuffer); + return graphicBuffer; +} + +void GraphicBufferAlloc::freeAllGraphicBuffersExcept(int bufIdx) { + Mutex::Autolock _l(mLock); + if (0 <= bufIdx && bufIdx < mBuffers.size()) { + sp<GraphicBuffer> b(mBuffers[bufIdx]); + mBuffers.clear(); + mBuffers.add(b); + } else { + mBuffers.clear(); + } +} + +// --------------------------------------------------------------------------- + GraphicPlane::GraphicPlane() : mHw(0) { diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 48642d4..2f2977a 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -34,6 +34,7 @@ #include <ui/PixelFormat.h> #include <surfaceflinger/ISurfaceComposer.h> #include <surfaceflinger/ISurfaceComposerClient.h> +#include <surfaceflinger/IGraphicBufferAlloc.h> #include "Barrier.h" #include "Layer.h" @@ -119,6 +120,21 @@ private: sp<SurfaceFlinger> mFlinger; }; +class GraphicBufferAlloc : public BnGraphicBufferAlloc +{ +public: + GraphicBufferAlloc(); + virtual ~GraphicBufferAlloc(); + + virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, + PixelFormat format, uint32_t usage); + virtual void freeAllGraphicBuffersExcept(int bufIdx); + +private: + Vector<sp<GraphicBuffer> > mBuffers; + Mutex mLock; +}; + // --------------------------------------------------------------------------- class GraphicPlane @@ -184,6 +200,7 @@ public: // ISurfaceComposer interface virtual sp<ISurfaceComposerClient> createConnection(); virtual sp<ISurfaceComposerClient> createClientConnection(); + virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc(); virtual sp<IMemoryHeap> getCblk() const; virtual void bootFinished(); virtual void openGlobalTransaction(); @@ -322,8 +339,6 @@ private: status_t electronBeamOnAnimationImplLocked(); status_t renderScreenToTextureLocked(DisplayID dpy, GLuint* textureName, GLfloat* uOut, GLfloat* vOut); - sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, - PixelFormat format, uint32_t usage) const; friend class FreezeLock; sp<FreezeLock> getFreezeLock() const; diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java index 4982c46..e5a46b9 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java @@ -93,11 +93,8 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel final VMRuntime runtime = VMRuntime.getRuntime(); runtime.gcSoftReferences(); - runtime.runFinalizationSync(); runtime.gcSoftReferences(); - runtime.runFinalizationSync(); runtime.gcSoftReferences(); - runtime.runFinalizationSync(); Runtime.getRuntime().runFinalization(); Runtime.getRuntime().gc(); Runtime.getRuntime().gc(); diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java index eb9487e..7020d9c 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java +++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java @@ -16,9 +16,9 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.ResourceDensity; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import android.content.res.AssetManager; import android.content.res.Resources; @@ -352,7 +352,7 @@ public class BitmapFactory { If the exception happened on open, bm will be null. If it happened on close, bm is still valid. */ - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_READ, + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, String.format("Error decoding bitmap of id 0x%x", id), e); } finally { try { @@ -452,7 +452,7 @@ public class BitmapFactory { Bitmap bm; if (is instanceof AssetManager.AssetInputStream) { - Bridge.getLog().error(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "Bitmap.decodeStream: " + "InputStream is unsupported (AssetManager.AssetInputStream)"); return null; diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java index 9d62415..03d65b2 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import android.graphics.Shader.TileMode; @@ -113,7 +113,7 @@ public class BitmapShader_Delegate extends Shader_Delegate { try { canvasMatrix = xform.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, "Unable to inverse matrix in BitmapShader", e); canvasMatrix = new java.awt.geom.AffineTransform(); } @@ -122,7 +122,7 @@ public class BitmapShader_Delegate extends Shader_Delegate { try { localMatrix = localMatrix.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, "Unable to inverse matrix in BitmapShader", e); localMatrix = new java.awt.geom.AffineTransform(); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java index 6acae7c..18bf4b5 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java @@ -16,9 +16,9 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.ResourceDensity; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import android.graphics.Bitmap.Config; @@ -249,7 +249,7 @@ public final class Bitmap_Delegate { /*package*/ static boolean nativeCompress(int nativeBitmap, int format, int quality, OutputStream stream, byte[] tempStorage) { - Bridge.getLog().error(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "Bitmap.compress() is not supported"); return true; } @@ -385,7 +385,7 @@ public final class Bitmap_Delegate { /*package*/ static Bitmap nativeCreateFromParcel(Parcel p) { // This is only called by Bitmap.CREATOR (Parcelable.Creator<Bitmap>), which is only // used during aidl call so really this should not be called. - Bridge.getLog().error(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "AIDL is not suppored, and therefore Bitmaps cannot be created from parcels."); return null; } @@ -394,7 +394,7 @@ public final class Bitmap_Delegate { int density, Parcel p) { // This is only called when sending a bitmap through aidl, so really this should not // be called. - Bridge.getLog().error(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "AIDL is not suppored, and therefore Bitmaps cannot be written to parcels."); return false; } @@ -410,7 +410,7 @@ public final class Bitmap_Delegate { Paint_Delegate paint = Paint_Delegate.getDelegate(nativePaint); if (paint != null && paint.getMaskFilter() != null) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MASKFILTER, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MASKFILTER, "MaskFilter not supported in Bitmap.extractAlpha", null); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java index cafe52d..0d9efba 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import com.android.layoutlib.bridge.impl.GcSnapshot; @@ -423,7 +423,7 @@ public final class Canvas_Delegate { if (matrixDelegate.hasPerspective()) { assert false; - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Canvas#setMatrix(android.graphics.Matrix) only " + "supports affine transformations.", null); } @@ -493,7 +493,7 @@ public final class Canvas_Delegate { } if (filterDelegate.isSupported() == false) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_DRAWFILTER, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_DRAWFILTER, filterDelegate.getSupportMessage(), null); } } diff --git a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java index 37d2c81..aab310a 100644 --- a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import android.graphics.Shader.TileMode; @@ -136,7 +136,7 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { try { canvasMatrix = xform.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, "Unable to inverse matrix in LinearGradient", e); canvasMatrix = new java.awt.geom.AffineTransform(); } @@ -145,7 +145,7 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { try { localMatrix = localMatrix.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, "Unable to inverse matrix in LinearGradient", e); localMatrix = new java.awt.geom.AffineTransform(); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java index 6d6c599..0c934fc 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java @@ -17,8 +17,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import android.graphics.Matrix.ScaleToFit; @@ -613,7 +613,7 @@ public final class Matrix_Delegate { /*package*/ static boolean native_setPolyToPoly(int native_object, float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount) { // FIXME - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Matrix.setPolyToPoly is not supported.", null); return false; diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java index 385def3..049ac45 100644 --- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import com.android.layoutlib.bridge.impl.GcSnapshot; import com.android.ninepatch.NinePatchChunk; @@ -197,11 +197,11 @@ public final class NinePatch_Delegate { sChunkCache.put(array, new SoftReference<NinePatchChunk>(chunk)); } } catch (IOException e) { - Bridge.getLog().error(BridgeConstants.TAG_BROKEN, + Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Failed to deserialize NinePatchChunk content.", e); return null; } catch (ClassNotFoundException e) { - Bridge.getLog().error(BridgeConstants.TAG_BROKEN, + Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Failed to deserialize NinePatchChunk class.", e); return null; } finally { diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java index 7db3486..67afeca 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import android.graphics.Paint.FontMetrics; @@ -180,7 +180,7 @@ public class Paint_Delegate { return stroke; } } else { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_PATHEFFECT, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_PATHEFFECT, effectDelegate.getSupportMessage(), null); } @@ -376,7 +376,7 @@ public class Paint_Delegate { /*package*/ static void nSetShadowLayer(Paint thisPaint, float radius, float dx, float dy, int color) { // FIXME - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Paint.setShadowLayer is not supported.", null); } @@ -693,7 +693,7 @@ public class Paint_Delegate { // since none of those are supported, display a fidelity warning right away ColorFilter_Delegate filterDelegate = delegate.getColorFilter(); if (filterDelegate != null && filterDelegate.isSupported() == false) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_COLORFILTER, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_COLORFILTER, filterDelegate.getSupportMessage(), null); } @@ -732,7 +732,7 @@ public class Paint_Delegate { // since none of those are supported, display a fidelity warning right away MaskFilter_Delegate filterDelegate = delegate.getMaskFilter(); if (filterDelegate != null && filterDelegate.isSupported() == false) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MASKFILTER, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MASKFILTER, filterDelegate.getSupportMessage(), null); } @@ -763,7 +763,7 @@ public class Paint_Delegate { // since none of those are supported, display a fidelity warning right away Rasterizer_Delegate rasterizerDelegate = delegate.getRasterizer(); if (rasterizerDelegate != null && rasterizerDelegate.isSupported() == false) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_RASTERIZER, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_RASTERIZER, rasterizerDelegate.getSupportMessage(), null); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java index ad9c9f9..62ea622 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import android.graphics.Path.Direction; @@ -696,7 +696,7 @@ public final class Path_Delegate { public void transform(Matrix_Delegate matrix, Path_Delegate dst) { if (matrix.hasPerspective()) { assert false; - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Path#transform() only " + "supports affine transformations.", null); } diff --git a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java index b09806c..314dcff 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import java.awt.AlphaComposite; @@ -73,7 +73,7 @@ public class PorterDuffXfermode_Delegate extends Xfermode_Delegate { } } - Bridge.getLog().error(BridgeConstants.TAG_BROKEN, + Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Unknown PorterDuff.Mode: %d", mode)); assert false; return PorterDuff.Mode.SRC_OVER; @@ -116,7 +116,7 @@ public class PorterDuffXfermode_Delegate extends Xfermode_Delegate { return AlphaComposite.getInstance(AlphaComposite.XOR, falpha); } - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_BROKEN, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_BROKEN, String.format("Unsupported PorterDuff Mode: %s", mode.name()), null); diff --git a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java index c86e808..2c26175 100644 --- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import android.graphics.Shader.TileMode; @@ -125,7 +125,7 @@ public class RadialGradient_Delegate extends Gradient_Delegate { try { canvasMatrix = xform.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, "Unable to inverse matrix in RadialGradient", e); canvasMatrix = new java.awt.geom.AffineTransform(); } @@ -134,7 +134,7 @@ public class RadialGradient_Delegate extends Gradient_Delegate { try { localMatrix = localMatrix.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, "Unable to inverse matrix in RadialGradient", e); localMatrix = new java.awt.geom.AffineTransform(); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java index b587563..f86c56c 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import android.os.Parcel; @@ -416,7 +416,7 @@ public class Region_Delegate { /*package*/ static int nativeCreateFromParcel(Parcel p) { // This is only called by Region.CREATOR (Parcelable.Creator<Region>), which is only // used during aidl call so really this should not be called. - Bridge.getLog().error(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "AIDL is not suppored, and therefore Regions cannot be created from parcels."); return 0; } @@ -425,7 +425,7 @@ public class Region_Delegate { Parcel p) { // This is only called when sending a region through aidl, so really this should not // be called. - Bridge.getLog().error(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "AIDL is not suppored, and therefore Regions cannot be written to parcels."); return false; } diff --git a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java index 9a84bdd..e812f7f 100644 --- a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; /** @@ -117,7 +117,7 @@ public class SweepGradient_Delegate extends Gradient_Delegate { try { canvasMatrix = xform.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, "Unable to inverse matrix in SweepGradient", e); canvasMatrix = new java.awt.geom.AffineTransform(); } @@ -126,7 +126,7 @@ public class SweepGradient_Delegate extends Gradient_Delegate { try { localMatrix = localMatrix.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_MATRIX, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, "Unable to inverse matrix in SweepGradient", e); localMatrix = new java.awt.geom.AffineTransform(); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java index c7d5490..44275d6 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java @@ -16,8 +16,8 @@ package android.graphics; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.DelegateManager; import com.android.layoutlib.bridge.impl.FontLoader; @@ -126,13 +126,13 @@ public final class Typeface_Delegate { } /*package*/ static synchronized int nativeCreateFromAsset(AssetManager mgr, String path) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Typeface.createFromAsset() is not supported.", null); return 0; } /*package*/ static synchronized int nativeCreateFromFile(String path) { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_UNSUPPORTED, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Typeface.createFromFile() is not supported.", null); return 0; } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java index e42f51c..6e9f4d5 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java @@ -262,7 +262,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge { } } catch (Throwable throwable) { if (log != null) { - log.error(BridgeConstants.TAG_BROKEN, + log.error(LayoutLog.TAG_BROKEN, "Failed to load com.android.internal.R from the layout library jar", throwable); } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java index f8e7592..194687e 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java @@ -64,18 +64,4 @@ public class BridgeConstants { public final static String MATCH_PARENT = "match_parent"; public final static String FILL_PARENT = "fill_parent"; public final static String WRAP_CONTENT = "wrap_content"; - - public final static String TAG_UNSUPPORTED = "unsupported"; - public static final String TAG_BROKEN = "broken"; - public final static String TAG_RESOURCES_RESOLVE = "resources.resolve"; - public final static String TAG_RESOURCES_READ = "resources.read"; - public final static String TAG_RESOURCES_FORMAT = "resources.format"; - public static final String TAG_MATRIX = "matrix"; - public final static String TAG_MASKFILTER = "maskfilter"; - public static final String TAG_DRAWFILTER = "drawfilter"; - public static final String TAG_PATHEFFECT = "patheffect"; - public static final String TAG_COLORFILTER = "colorfilter"; - public static final String TAG_RASTERIZER = "rasterizer"; - public static final String TAG_SHADER = "shader"; - public static final String TAG_XFERMODE = "xfermode"; } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index 11a0552..dc027b7 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -17,6 +17,7 @@ package com.android.layoutlib.bridge.android; import com.android.ide.common.rendering.api.IProjectCallback; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.common.rendering.api.StyleResourceValue; import com.android.layoutlib.bridge.Bridge; @@ -336,7 +337,7 @@ public final class BridgeContext extends Activity { isPlatformFile = false; } else if (set != null) { // null parser is ok // really this should not be happening since its instantiated in Bridge - Bridge.getLog().error(BridgeConstants.TAG_BROKEN, + Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Parser is not a BridgeXmlBlockParser!"); return null; } @@ -706,7 +707,7 @@ public final class BridgeContext extends Activity { // This is normal if the resource is an ID that is generated automatically. // For other resources, we output a warning if ("+id".equals(resType) == false && "+android:id".equals(resType) == false) { //$NON-NLS-1$ //$NON-NLS-2$ - Bridge.getLog().warning(BridgeConstants.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, "Couldn't resolve resource @" + (frameworkOnly ? "android:" : "") + resType + "/" + resName); } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java index c739b4f..61ac81b 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java @@ -17,6 +17,7 @@ package com.android.layoutlib.bridge.android; import com.android.ide.common.rendering.api.IProjectCallback; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; @@ -178,7 +179,7 @@ public final class BridgeInflater extends LayoutInflater { return inflate(bridgeParser, root); } catch (Exception e) { - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_READ, + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, "Failed to parse file " + f.getAbsolutePath(), e); return null; diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java index eacfed6..8446a99 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java @@ -17,6 +17,7 @@ package com.android.layoutlib.bridge.android; import com.android.ide.common.rendering.api.IProjectCallback; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; @@ -142,7 +143,7 @@ public final class BridgeResources extends Resources { try { return ResourceHelper.getColor(value.getValue()); } catch (NumberFormatException e) { - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_FORMAT, e.getMessage(), e); + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e); return 0; } } @@ -174,13 +175,13 @@ public final class BridgeResources extends Resources { return ColorStateList.createFromXml(this, new BridgeXmlBlockParser(parser, mContext, resValue.isFramework())); } catch (XmlPullParserException e) { - Bridge.getLog().error(BridgeConstants.TAG_BROKEN, + Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Failed to configure parser for " + value, e); // we'll return null below. } catch (Exception e) { // this is an error and not warning since the file existence is checked before // attempting to parse it. - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_READ, + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, "Failed to parse file " + value, e); return null; @@ -191,7 +192,7 @@ public final class BridgeResources extends Resources { int color = ResourceHelper.getColor(value); return ColorStateList.valueOf(color); } catch (NumberFormatException e) { - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_FORMAT, + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, "Failed to convert " + value + " into a ColorStateList", e); return null; } @@ -251,7 +252,7 @@ public final class BridgeResources extends Resources { return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]); } } catch (XmlPullParserException e) { - Bridge.getLog().error(BridgeConstants.TAG_BROKEN, + Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Failed to configure parser for " + value.getValue(), e); // we'll return null below. } catch (FileNotFoundException e) { @@ -286,7 +287,7 @@ public final class BridgeResources extends Resources { return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]); } } catch (XmlPullParserException e) { - Bridge.getLog().error(BridgeConstants.TAG_BROKEN, + Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Failed to configure parser for " + value.getValue(), e); // we'll return null below. } catch (FileNotFoundException e) { diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java index 79b3a73..42f05e3 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java @@ -16,6 +16,7 @@ package com.android.layoutlib.bridge.android; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.common.rendering.api.StyleResourceValue; import com.android.internal.util.XmlUtils; @@ -206,7 +207,7 @@ public final class BridgeTypedArray extends TypedArray { if (i != null) { result |= i.intValue(); } else { - Bridge.getLog().warning(BridgeConstants.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, String.format( "Unknown constant \"%s\" in attribute \"%2$s\"", keyword, mNames[index])); @@ -237,7 +238,7 @@ public final class BridgeTypedArray extends TypedArray { try { return Float.parseFloat(s); } catch (NumberFormatException e) { - Bridge.getLog().warning(BridgeConstants.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, String.format( "Unable to convert \"%s\" into a float in attribute \"%2$s\"", s, mNames[index])); @@ -270,7 +271,7 @@ public final class BridgeTypedArray extends TypedArray { try { return ResourceHelper.getColor(s); } catch (NumberFormatException e) { - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_FORMAT, e.getMessage(), e); + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e); // we'll return the default value below. } @@ -313,13 +314,13 @@ public final class BridgeTypedArray extends TypedArray { new BridgeXmlBlockParser(parser, mContext, false)); return colorStateList; } catch (XmlPullParserException e) { - Bridge.getLog().error(BridgeConstants.TAG_BROKEN, + Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Failed to configure parser for " + value, e); return null; } catch (Exception e) { // this is an error and not warning since the file existence is checked before // attempting to parse it. - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_READ, + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, "Failed to parse file " + value, e); return null; @@ -330,7 +331,7 @@ public final class BridgeTypedArray extends TypedArray { int color = ResourceHelper.getColor(value); return ColorStateList.valueOf(color); } catch (NumberFormatException e) { - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_FORMAT, e.getMessage(), e); + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e); } assert false; @@ -359,7 +360,7 @@ public final class BridgeTypedArray extends TypedArray { try { return Integer.parseInt(s); } catch (NumberFormatException e) { - Bridge.getLog().warning(BridgeConstants.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, String.format( "Unable to convert \"%s\" into a integer in attribute \"%2$s\"", s, mNames[index])); @@ -409,7 +410,7 @@ public final class BridgeTypedArray extends TypedArray { } // looks like we were unable to resolve the dimension value - Bridge.getLog().warning(BridgeConstants.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, String.format( "Unable to resolve dimension value \"%1$s\" in attribute \"%2$s\"", s, mNames[index])); @@ -541,7 +542,7 @@ public final class BridgeTypedArray extends TypedArray { } // looks like we were unable to resolve the fraction value - Bridge.getLog().warning(BridgeConstants.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, String.format( "Unable to resolve fraction value \"%1$s\" in attribute \"%2$s\"", value, mNames[index])); @@ -653,7 +654,7 @@ public final class BridgeTypedArray extends TypedArray { return idValue.intValue(); } - Bridge.getLog().warning(BridgeConstants.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, String.format( "Unable to resolve id \"%1$s\" for attribute \"%2$s\"", value, mNames[index])); @@ -691,7 +692,7 @@ public final class BridgeTypedArray extends TypedArray { } // looks like we were unable to resolve the drawable - Bridge.getLog().warning(BridgeConstants.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, String.format( "Unable to resolve drawable \"%1$s\" in attribute \"%2$s\"", stringValue, mNames[index])); @@ -723,7 +724,7 @@ public final class BridgeTypedArray extends TypedArray { return new CharSequence[] { value }; } - Bridge.getLog().warning(BridgeConstants.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, String.format( String.format("Unknown value for getTextArray(%d) => %s", //DEBUG index, mResourceData[index].getName()))); diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java index 94075dc..b3f1fff 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java @@ -16,8 +16,8 @@ package com.android.layoutlib.bridge.impl; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import android.graphics.Bitmap_Delegate; import android.graphics.Canvas; @@ -729,7 +729,7 @@ public class GcSnapshot { customShader = true; } } else { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_SHADER, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER, shaderDelegate.getSupportMessage(), null); } @@ -763,7 +763,7 @@ public class GcSnapshot { customXfermode = true; } } else { - Bridge.getLog().fidelityWarning(BridgeConstants.TAG_XFERMODE, + Bridge.getLog().fidelityWarning(LayoutLog.TAG_XFERMODE, xfermodeDelegate.getSupportMessage(), null); } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java index a690777..566d4d4 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java @@ -1045,7 +1045,7 @@ public class RenderSessionImpl { } assert false; - mParams.getLog().error(BridgeConstants.TAG_RESOURCES_RESOLVE, + mParams.getLog().error(LayoutLog.TAG_RESOURCES_RESOLVE, String.format("Unable to resolve parent style name: %s", parentName)); return null; diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java index b9aa80c..4e331d1 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java @@ -17,10 +17,10 @@ package com.android.layoutlib.bridge.impl; import com.android.ide.common.rendering.api.DensityBasedResourceValue; +import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.ResourceDensity; import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.Bridge; -import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.android.BridgeContext; import com.android.layoutlib.bridge.android.BridgeXmlBlockParser; import com.android.ninepatch.NinePatch; @@ -165,7 +165,7 @@ public final class ResourceHelper { // URL is wrong, we'll return null below } catch (IOException e) { // failed to read the file, we'll return null below. - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_READ, + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, "Failed lot load " + file.getAbsolutePath(), e); } } @@ -200,7 +200,7 @@ public final class ResourceHelper { Bridge.getLog().error(null, "Failed to parse file " + value, e); } } else { - Bridge.getLog().error(BridgeConstants.TAG_BROKEN, + Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("File %s does not exist (or is not a file)", stringValue)); } @@ -227,7 +227,7 @@ public final class ResourceHelper { return new BitmapDrawable(context.getResources(), bitmap); } catch (IOException e) { // we'll return null below - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_READ, + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, "Failed lot load " + bmpFile.getAbsolutePath(), e); } } else { @@ -237,7 +237,7 @@ public final class ResourceHelper { return new ColorDrawable(color); } catch (NumberFormatException e) { // we'll return null below. - Bridge.getLog().error(BridgeConstants.TAG_RESOURCES_FORMAT, + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, "Failed to convert " + stringValue + " into a drawable", e); } } |