diff options
55 files changed, 893 insertions, 330 deletions
diff --git a/api/current.xml b/api/current.xml index 6059946..805917b 100644 --- a/api/current.xml +++ b/api/current.xml @@ -15944,6 +15944,17 @@ <parameter name="data" type="android.content.Intent"> </parameter> </method> +<method name="onAttachedToWindow" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="onChildTitleChanged" return="void" abstract="false" @@ -16147,6 +16158,17 @@ visibility="protected" > </method> +<method name="onDetachedFromWindow" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="onKeyDown" return="boolean" abstract="false" @@ -19677,6 +19699,17 @@ visibility="public" > </method> +<method name="onAttachedToWindow" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="onContentChanged" return="void" abstract="false" @@ -19785,6 +19818,17 @@ <parameter name="featureId" type="int"> </parameter> </method> +<method name="onDetachedFromWindow" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="onKeyDown" return="boolean" abstract="false" @@ -21731,6 +21775,30 @@ visibility="public" > </method> +<method name="onQueryPackageManager" + return="java.util.List<android.content.pm.ResolveInfo>" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="protected" +> +<parameter name="queryIntent" type="android.content.Intent"> +</parameter> +</method> +<method name="onSetContentView" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="protected" +> +</method> </class> <class name="LauncherActivity.IconResizer" extends="java.lang.Object" @@ -25311,6 +25379,19 @@ visibility="public" > </method> +<method name="reset" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<exception name="RemoteException" type="android.os.RemoteException"> +</exception> +</method> </class> <class name="ActivityNotFoundException" extends="java.lang.RuntimeException" @@ -31226,6 +31307,19 @@ <exception name="RemoteException" type="android.os.RemoteException"> </exception> </method> +<method name="reset" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<exception name="RemoteException" type="android.os.RemoteException"> +</exception> +</method> </interface> <class name="Intent" extends="java.lang.Object" @@ -154591,6 +154685,17 @@ <parameter name="event" type="android.view.MotionEvent"> </parameter> </method> +<method name="onAttachedToWindow" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="onContentChanged" return="void" abstract="true" @@ -154630,6 +154735,17 @@ <parameter name="featureId" type="int"> </parameter> </method> +<method name="onDetachedFromWindow" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="onMenuItemSelected" return="boolean" abstract="true" diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 10e6299..80d7285 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -1930,11 +1930,32 @@ public class Activity extends ContextThemeWrapper * * @see #hasWindowFocus() * @see #onResume + * @see View#onWindowFocusChanged(boolean) */ public void onWindowFocusChanged(boolean hasFocus) { } /** + * Called when the main window associated with the activity has been + * attached to the window manager. + * See {@link View#onAttachedToWindow() View.onAttachedToWindow()} + * for more information. + * @see View#onAttachedToWindow + */ + public void onAttachedToWindow() { + } + + /** + * Called when the main window associated with the activity has been + * detached from the window manager. + * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()} + * for more information. + * @see View#onDetachedFromWindow + */ + public void onDetachedFromWindow() { + } + + /** * Returns true if this activity's <em>main</em> window currently has window focus. * Note that this is not the same as the view itself having focus. * diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index 9432755..35d1004 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -576,6 +576,12 @@ public class Dialog implements DialogInterface, Window.Callback, public void onWindowFocusChanged(boolean hasFocus) { } + public void onAttachedToWindow() { + } + + public void onDetachedFromWindow() { + } + /** * Called to process key events. You can override this to intercept all * key events before they are dispatched to the window. Be sure to call diff --git a/core/java/android/app/LauncherActivity.java b/core/java/android/app/LauncherActivity.java index d788c43..a83f4e8 100644 --- a/core/java/android/app/LauncherActivity.java +++ b/core/java/android/app/LauncherActivity.java @@ -18,6 +18,7 @@ package android.app; import android.content.Context; import android.content.Intent; +import android.content.pm.ComponentInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; @@ -70,13 +71,15 @@ public abstract class LauncherActivity extends ListActivity { ListItem(PackageManager pm, ResolveInfo resolveInfo, IconResizer resizer) { this.resolveInfo = resolveInfo; label = resolveInfo.loadLabel(pm); - if (label == null && resolveInfo.activityInfo != null) { + ComponentInfo ci = resolveInfo.activityInfo; + if (ci == null) ci = resolveInfo.serviceInfo; + if (label == null && ci != null) { label = resolveInfo.activityInfo.name; } icon = resizer.createIconThumbnail(resolveInfo.loadIcon(pm)); - packageName = resolveInfo.activityInfo.applicationInfo.packageName; - className = resolveInfo.activityInfo.name; + packageName = ci.applicationInfo.packageName; + className = ci.name; } public ListItem() { @@ -325,8 +328,7 @@ public abstract class LauncherActivity extends ListActivity { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarIndeterminateVisibility(true); - setContentView(com.android.internal.R.layout.activity_list); - + onSetContentView(); mIntent = new Intent(getTargetIntent()); mIntent.setComponent(null); @@ -338,10 +340,17 @@ public abstract class LauncherActivity extends ListActivity { setProgressBarIndeterminateVisibility(false); } + /** + * Override to call setContentView() with your own content view to + * customize the list layout. + */ + protected void onSetContentView() { + setContentView(com.android.internal.R.layout.activity_list); + } + @Override protected void onListItemClick(ListView l, View v, int position, long id) { - Intent intent = ((ActivityAdapter)mAdapter).intentForPosition(position); - + Intent intent = intentForPosition(position); startActivity(intent); } @@ -374,12 +383,19 @@ public abstract class LauncherActivity extends ListActivity { } /** + * Perform query on package manager for list items. The default + * implementation queries for activities. + */ + protected List<ResolveInfo> onQueryPackageManager(Intent queryIntent) { + return mPackageManager.queryIntentActivities(queryIntent, /* no flags */ 0); + } + + /** * Perform the query to determine which results to show and return a list of them. */ public List<ListItem> makeListItems() { // Load all matching activities and sort correctly - List<ResolveInfo> list = mPackageManager.queryIntentActivities(mIntent, - /* no flags */ 0); + List<ResolveInfo> list = onQueryPackageManager(mIntent); Collections.sort(list, new ResolveInfo.DisplayNameComparator(mPackageManager)); IconResizer resizer = new IconResizer(); diff --git a/core/java/android/content/AbstractCursorEntityIterator.java b/core/java/android/content/AbstractCursorEntityIterator.java index bf3c4de..c2b13a4 100644 --- a/core/java/android/content/AbstractCursorEntityIterator.java +++ b/core/java/android/content/AbstractCursorEntityIterator.java @@ -87,6 +87,14 @@ public abstract class AbstractCursorEntityIterator implements EntityIterator { } } + public void reset() throws RemoteException { + if (mIsClosed) { + throw new IllegalStateException("calling reset() when the iterator is closed"); + } + mEntityCursor.moveToPosition(-1); + mNextEntity = null; + } + /** * Closes this iterator making it invalid. If is invalid for the user to call any public * method on the iterator once it has been closed. diff --git a/core/java/android/content/ContentProviderNative.java b/core/java/android/content/ContentProviderNative.java index a4c217b..e367ceb 100644 --- a/core/java/android/content/ContentProviderNative.java +++ b/core/java/android/content/ContentProviderNative.java @@ -281,6 +281,10 @@ abstract public class ContentProviderNative extends Binder implements IContentPr return mEntityIterator.next(); } + public void reset() throws RemoteException { + mEntityIterator.reset(); + } + public void close() throws RemoteException { mEntityIterator.close(); } @@ -406,6 +410,10 @@ final class ContentProviderProxy implements IContentProvider return mEntityIterator.next(); } + public void reset() throws RemoteException { + mEntityIterator.reset(); + } + public void close() { try { mEntityIterator.close(); diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java index 239b3de..b915803 100644 --- a/core/java/android/content/ContentResolver.java +++ b/core/java/android/content/ContentResolver.java @@ -244,6 +244,13 @@ public abstract class ContentResolver { return mInner.next(); } + public void reset() throws RemoteException { + if (mClientReleased) { + throw new IllegalStateException("this iterator is already closed"); + } + mInner.reset(); + } + public void close() { mClient.release(); mInner.close(); diff --git a/core/java/android/content/EntityIterator.java b/core/java/android/content/EntityIterator.java index 5e5f14c..3cc1040 100644 --- a/core/java/android/content/EntityIterator.java +++ b/core/java/android/content/EntityIterator.java @@ -41,6 +41,8 @@ public interface EntityIterator { */ public Entity next() throws RemoteException; + public void reset() throws RemoteException; + /** * Indicates that this iterator is no longer needed and that any associated resources * may be released (such as a SQLite cursor). diff --git a/core/java/android/content/IEntityIterator.java b/core/java/android/content/IEntityIterator.java index 1c478b3..068581e 100644 --- a/core/java/android/content/IEntityIterator.java +++ b/core/java/android/content/IEntityIterator.java @@ -98,6 +98,20 @@ public interface IEntityIterator extends IInterface { return true; } + case TRANSACTION_reset: + { + data.enforceInterface(DESCRIPTOR); + try { + this.reset(); + } catch (RemoteException e) { + Log.e(TAG, "caught exception in next()", e); + reply.writeException(e); + return true; + } + reply.writeNoException(); + return true; + } + case TRANSACTION_close: { data.enforceInterface(DESCRIPTOR); @@ -157,6 +171,19 @@ public interface IEntityIterator extends IInterface { } } + public void reset() throws RemoteException { + Parcel _data = Parcel.obtain(); + Parcel _reply = Parcel.obtain(); + try { + _data.writeInterfaceToken(DESCRIPTOR); + mRemote.transact(Stub.TRANSACTION_reset, _data, _reply, 0); + _reply.readException(); + } finally { + _reply.recycle(); + _data.recycle(); + } + } + public void close() throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); @@ -174,8 +201,10 @@ public interface IEntityIterator extends IInterface { static final int TRANSACTION_hasNext = (IBinder.FIRST_CALL_TRANSACTION + 0); static final int TRANSACTION_next = (IBinder.FIRST_CALL_TRANSACTION + 1); static final int TRANSACTION_close = (IBinder.FIRST_CALL_TRANSACTION + 2); + static final int TRANSACTION_reset = (IBinder.FIRST_CALL_TRANSACTION + 3); } public boolean hasNext() throws RemoteException; public Entity next() throws RemoteException; + public void reset() throws RemoteException; public void close() throws RemoteException; } diff --git a/core/java/android/content/SyncResult.java b/core/java/android/content/SyncResult.java index f3260f3..4c201e6 100644 --- a/core/java/android/content/SyncResult.java +++ b/core/java/android/content/SyncResult.java @@ -113,14 +113,19 @@ public final class SyncResult implements Parcelable { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append(" syncAlreadyInProgress: ").append(syncAlreadyInProgress); - sb.append(" tooManyDeletions: ").append(tooManyDeletions); - sb.append(" tooManyRetries: ").append(tooManyRetries); - sb.append(" databaseError: ").append(databaseError); - sb.append(" fullSyncRequested: ").append(fullSyncRequested); - sb.append(" partialSyncUnavailable: ").append(partialSyncUnavailable); - sb.append(" moreRecordsToGet: ").append(moreRecordsToGet); - sb.append(" stats: ").append(stats); + sb.append("SyncResult:"); + if (syncAlreadyInProgress) { + sb.append(" syncAlreadyInProgress: ").append(syncAlreadyInProgress); + } + if (tooManyDeletions) sb.append(" tooManyDeletions: ").append(tooManyDeletions); + if (tooManyRetries) sb.append(" tooManyRetries: ").append(tooManyRetries); + if (databaseError) sb.append(" databaseError: ").append(databaseError); + if (fullSyncRequested) sb.append(" fullSyncRequested: ").append(fullSyncRequested); + if (partialSyncUnavailable) { + sb.append(" partialSyncUnavailable: ").append(partialSyncUnavailable); + } + if (moreRecordsToGet) sb.append(" moreRecordsToGet: ").append(moreRecordsToGet); + sb.append(stats); return sb.toString(); } diff --git a/core/java/android/content/SyncStats.java b/core/java/android/content/SyncStats.java index b561b05..cc544c0 100644 --- a/core/java/android/content/SyncStats.java +++ b/core/java/android/content/SyncStats.java @@ -60,15 +60,18 @@ public class SyncStats implements Parcelable { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("numAuthExceptions: ").append(numAuthExceptions); - sb.append(" numIoExceptions: ").append(numIoExceptions); - sb.append(" numParseExceptions: ").append(numParseExceptions); - sb.append(" numConflictDetectedExceptions: ").append(numConflictDetectedExceptions); - sb.append(" numInserts: ").append(numInserts); - sb.append(" numUpdates: ").append(numUpdates); - sb.append(" numDeletes: ").append(numDeletes); - sb.append(" numEntries: ").append(numEntries); - sb.append(" numSkippedEntries: ").append(numSkippedEntries); + sb.append(" stats ["); + if (numAuthExceptions > 0) sb.append(" numAuthExceptions: ").append(numAuthExceptions); + if (numIoExceptions > 0) sb.append(" numIoExceptions: ").append(numIoExceptions); + if (numParseExceptions > 0) sb.append(" numParseExceptions: ").append(numParseExceptions); + if (numConflictDetectedExceptions > 0) + sb.append(" numConflictDetectedExceptions: ").append(numConflictDetectedExceptions); + if (numInserts > 0) sb.append(" numInserts: ").append(numInserts); + if (numUpdates > 0) sb.append(" numUpdates: ").append(numUpdates); + if (numDeletes > 0) sb.append(" numDeletes: ").append(numDeletes); + if (numEntries > 0) sb.append(" numEntries: ").append(numEntries); + if (numSkippedEntries > 0) sb.append(" numSkippedEntries: ").append(numSkippedEntries); + sb.append("]"); return sb.toString(); } diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java index deaa3c3..a97b9e5 100644 --- a/core/java/android/net/SSLCertificateSocketFactory.java +++ b/core/java/android/net/SSLCertificateSocketFactory.java @@ -41,6 +41,7 @@ import javax.net.ssl.X509TrustManager; import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache; import org.apache.harmony.xnet.provider.jsse.SSLContextImpl; +import org.apache.harmony.xnet.provider.jsse.SSLParameters; /** * SSLSocketFactory that provides optional (on debug devices, only) skipping of ssl certificfate @@ -54,28 +55,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { private static final String LOG_TAG = "SSLCertificateSocketFactory"; - private static X509TrustManager sDefaultTrustManager; - - static { - try { - TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509"); - tmf.init((KeyStore)null); - TrustManager[] tms = tmf.getTrustManagers(); - if (tms != null) { - for (TrustManager tm : tms) { - if (tm instanceof X509TrustManager) { - sDefaultTrustManager = (X509TrustManager)tm; - break; - } - } - } - } catch (NoSuchAlgorithmException e) { - Log.e(LOG_TAG, "Unable to get X509 Trust Manager ", e); - } catch (KeyStoreException e) { - Log.e(LOG_TAG, "Key Store exception while initializing TrustManagerFactory ", e); - } - } - private static final TrustManager[] TRUST_MANAGER = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { @@ -155,20 +134,13 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { private boolean hasValidCertificateChain(Certificate[] certs) throws IOException { - if (sDefaultTrustManager == null) { - if (Config.LOGD) { - Log.d(LOG_TAG,"hasValidCertificateChain():" + - " null default trust manager!"); - } - throw new IOException("null default trust manager"); - } - boolean trusted = (certs != null && (certs.length > 0)); if (trusted) { try { // the authtype we pass in doesn't actually matter - sDefaultTrustManager.checkServerTrusted((X509Certificate[]) certs, "RSA"); + SSLParameters.getDefaultTrustManager() + .checkServerTrusted((X509Certificate[]) certs, "RSA"); } catch (GeneralSecurityException e) { String exceptionMessage = e != null ? e.getMessage() : "none"; if (Config.LOGD) { diff --git a/core/java/android/net/http/CertificateChainValidator.java b/core/java/android/net/http/CertificateChainValidator.java index 91fa900..ed6b4c2 100644 --- a/core/java/android/net/http/CertificateChainValidator.java +++ b/core/java/android/net/http/CertificateChainValidator.java @@ -16,6 +16,8 @@ package android.net.http; +import org.apache.harmony.xnet.provider.jsse.SSLParameters; + import java.io.IOException; import java.security.cert.Certificate; @@ -47,11 +49,6 @@ class CertificateChainValidator { = new CertificateChainValidator(); /** - * Default trust manager (used to perform CA certificate validation) - */ - private X509TrustManager mDefaultTrustManager; - - /** * @return The singleton instance of the certificator chain validator */ public static CertificateChainValidator getInstance() { @@ -62,28 +59,7 @@ class CertificateChainValidator { * Creates a new certificate chain validator. This is a pivate constructor. * If you need a Certificate chain validator, call getInstance(). */ - private CertificateChainValidator() { - try { - TrustManagerFactory trustManagerFactory - = TrustManagerFactory.getInstance("X509"); - trustManagerFactory.init((KeyStore)null); - TrustManager[] trustManagers = - trustManagerFactory.getTrustManagers(); - if (trustManagers != null && trustManagers.length > 0) { - for (TrustManager trustManager : trustManagers) { - if (trustManager instanceof X509TrustManager) { - mDefaultTrustManager = (X509TrustManager)(trustManager); - break; - } - } - } - } catch (Exception exc) { - if (HttpLog.LOGV) { - HttpLog.v("CertificateChainValidator():" + - " failed to initialize the trust manager"); - } - } - } + private CertificateChainValidator() {} /** * Performs the handshake and server certificates validation @@ -156,7 +132,7 @@ class CertificateChainValidator { // report back to the user. // try { - mDefaultTrustManager.checkServerTrusted( + SSLParameters.getDefaultTrustManager().checkServerTrusted( serverCertificates, "RSA"); // no errors!!! @@ -186,7 +162,7 @@ class CertificateChainValidator { // check if the last certificate in the chain (root) is trusted X509Certificate[] rootCertificateChain = { currCertificate }; try { - mDefaultTrustManager.checkServerTrusted( + SSLParameters.getDefaultTrustManager().checkServerTrusted( rootCertificateChain, "RSA"); } catch (CertificateExpiredException e) { String errorMessage = e.getMessage(); diff --git a/core/java/android/service/wallpaper/IWallpaperService.aidl b/core/java/android/service/wallpaper/IWallpaperService.aidl index eb58c3b..bc7a1d7 100644 --- a/core/java/android/service/wallpaper/IWallpaperService.aidl +++ b/core/java/android/service/wallpaper/IWallpaperService.aidl @@ -23,5 +23,6 @@ import android.service.wallpaper.IWallpaperConnection; */ oneway interface IWallpaperService { void attach(IWallpaperConnection connection, - IBinder windowToken, int reqWidth, int reqHeight); + IBinder windowToken, int windowType, boolean isPreview, + int reqWidth, int reqHeight); } diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 5bb07f3..629e97e 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -212,6 +212,15 @@ public abstract class WallpaperService extends Service { } /** + * Returns true if this engine is running in preview mode -- that is, + * it is being shown to the user before they select it as the actual + * wallpaper. + */ + public boolean isPreview() { + return mIWallpaperEngine.mIsPreview; + } + + /** * Control whether this wallpaper will receive raw touch events * from the window manager as the user interacts with the window * that is currently displaying the wallpaper. By default they @@ -332,7 +341,7 @@ public abstract class WallpaperService extends Service { mLayout.token = mWindowToken; if (!mCreated) { - mLayout.type = WindowManager.LayoutParams.TYPE_WALLPAPER; + mLayout.type = mIWallpaperEngine.mWindowType; mLayout.gravity = Gravity.LEFT|Gravity.TOP; mSession.add(mWindow, mLayout, View.VISIBLE, mContentInsets); } @@ -465,6 +474,8 @@ public abstract class WallpaperService extends Service { final IWallpaperConnection mConnection; final IBinder mWindowToken; + final int mWindowType; + final boolean mIsPreview; int mReqWidth; int mReqHeight; @@ -472,10 +483,12 @@ public abstract class WallpaperService extends Service { IWallpaperEngineWrapper(WallpaperService context, IWallpaperConnection conn, IBinder windowToken, - int reqWidth, int reqHeight) { + int windowType, boolean isPreview, int reqWidth, int reqHeight) { mCaller = new HandlerCaller(context, this); mConnection = conn; mWindowToken = windowToken; + mWindowType = windowType; + mIsPreview = isPreview; mReqWidth = reqWidth; mReqHeight = reqHeight; @@ -567,10 +580,10 @@ public abstract class WallpaperService extends Service { mTarget = context; } - public void attach(IWallpaperConnection conn, - IBinder windowToken, int reqWidth, int reqHeight) { - new IWallpaperEngineWrapper( - mTarget, conn, windowToken, reqWidth, reqHeight); + public void attach(IWallpaperConnection conn, IBinder windowToken, + int windowType, boolean isPreview, int reqWidth, int reqHeight) { + new IWallpaperEngineWrapper(mTarget, conn, windowToken, + windowType, isPreview, reqWidth, reqHeight); } } diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 02e0515..1932765 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -237,7 +237,6 @@ public abstract class Window { /** * This is called whenever the current window attributes change. * - */ public void onWindowAttributesChanged(WindowManager.LayoutParams attrs); @@ -252,13 +251,29 @@ public abstract class Window { public void onContentChanged(); /** - * This hook is called whenever the window focus changes. + * This hook is called whenever the window focus changes. See + * {@link View#onWindowFocusChanged(boolean) + * View.onWindowFocusChanged(boolean)} for more information. * * @param hasFocus Whether the window now has focus. */ public void onWindowFocusChanged(boolean hasFocus); /** + * Called when the window has been attached to the window manager. + * See {@link View#onAttachedToWindow() View.onAttachedToWindow()} + * for more information. + */ + public void onAttachedToWindow(); + + /** + * Called when the window has been attached to the window manager. + * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()} + * for more information. + */ + public void onDetachedFromWindow(); + + /** * Called when a panel is being closed. If another logical subsequent * panel is being opened (and this panel is being closed to make room for the subsequent * panel), this method will NOT be called. diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java index 2da777a..67c0def 100644 --- a/core/java/android/widget/FastScroller.java +++ b/core/java/android/widget/FastScroller.java @@ -55,7 +55,7 @@ class FastScroller { private int mThumbY; private RectF mOverlayPos; - private int mOverlaySize = 104; + private int mOverlaySize; private AbsListView mList; private boolean mScrollCompleted; @@ -119,10 +119,10 @@ class FastScroller { private void useThumbDrawable(Context context, Drawable drawable) { mThumbDrawable = drawable; - mThumbW = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, - 64, context.getResources().getDisplayMetrics()); - mThumbH = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, - 52, context.getResources().getDisplayMetrics()); + mThumbW = context.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.fastscroll_thumb_width); + mThumbH = context.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.fastscroll_thumb_height); mChangedBounds = true; } @@ -138,7 +138,9 @@ class FastScroller { mScrollCompleted = true; getSectionsFromIndexer(); - + + mOverlaySize = context.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.fastscroll_overlay_size); mOverlayPos = new RectF(); mScrollFade = new ScrollFade(); mPaint = new Paint(); diff --git a/core/res/res/drawable/contact_picture_bg.9.png b/core/res/res/drawable/contact_picture_bg.9.png Binary files differdeleted file mode 100644 index ae9c709..0000000 --- a/core/res/res/drawable/contact_picture_bg.9.png +++ /dev/null diff --git a/core/res/res/drawable/fasttrack_badge_middle.xml b/core/res/res/drawable/fasttrack_badge_middle.xml new file mode 100644 index 0000000..6df230a --- /dev/null +++ b/core/res/res/drawable/fasttrack_badge_middle.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 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. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:state_focused="false" + android:state_selected="false" + android:state_pressed="false" + android:drawable="@drawable/fasttrack_badge_middle_normal" /> + + <item + android:state_pressed="true" + android:drawable="@drawable/fasttrack_badge_middle_pressed" /> + +</selector>
\ No newline at end of file diff --git a/core/res/res/drawable/fasttrack_badge_middle_normal.9.png b/core/res/res/drawable/fasttrack_badge_middle_normal.9.png Binary files differnew file mode 100644 index 0000000..1ac6ef9 --- /dev/null +++ b/core/res/res/drawable/fasttrack_badge_middle_normal.9.png diff --git a/core/res/res/drawable/fasttrack_badge_middle_pressed.9.png b/core/res/res/drawable/fasttrack_badge_middle_pressed.9.png Binary files differnew file mode 100644 index 0000000..33921ba --- /dev/null +++ b/core/res/res/drawable/fasttrack_badge_middle_pressed.9.png diff --git a/core/res/res/layout-ja/contact_header_name.xml b/core/res/res/layout-ja/contact_header_name.xml index 20df5c6..9dceeb6 100644 --- a/core/res/res/layout-ja/contact_header_name.xml +++ b/core/res/res/layout-ja/contact_header_name.xml @@ -27,8 +27,8 @@ android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="end" - android:textAppearance="?android:attr/textAppearanceLargeInverse" - android:textColor="@android:color/secondary_text_light" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textStyle="bold" /> <TextView android:id="@+id/phonetic_name" @@ -36,8 +36,7 @@ android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="end" - android:textAppearance="?android:attr/textAppearanceSmallInverse" - android:textColor="@android:color/secondary_text_light" + android:textAppearance="?android:attr/textAppearanceSmall" /> </LinearLayout> diff --git a/core/res/res/layout/contact_header.xml b/core/res/res/layout/contact_header.xml index 73e379b..8c1957d 100644 --- a/core/res/res/layout/contact_header.xml +++ b/core/res/res/layout/contact_header.xml @@ -15,26 +15,27 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/banner" + android:id="@+id/banner" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:background="@drawable/contact_header_bg" + android:background="@drawable/title_bar_tall" android:paddingRight="5dip" android:gravity="center_vertical"> <ImageView android:id="@+id/photo" - android:layout_width="64dip" + android:layout_width="56dip" android:layout_height="64dip" - android:layout_marginRight="7dip" - android:layout_marginLeft="2dip" + android:layout_marginRight="10dip" + android:layout_marginLeft="10dip" android:scaleType="fitCenter" - android:background="@drawable/contact_picture_bg"/> + android:background="@drawable/fasttrack_badge_middle"/> <LinearLayout android:layout_width="0dip" - android:layout_height="fill_parent" + android:layout_height="wrap_content" android:layout_weight="1" + android:layout_marginTop="5dip" android:orientation="vertical"> <!-- "Name" field is locale-specific. --> @@ -42,9 +43,11 @@ <TextView android:id="@+id/status" android:layout_width="fill_parent" - android:layout_height="wrap_content" + android:layout_height="0dip" + android:layout_weight="1" android:textAppearance="?android:attr/textAppearanceSmall" - android:maxLines="2"/> + android:maxLines="2" + android:ellipsize="end"/> </LinearLayout> diff --git a/core/res/res/layout/contact_header_name.xml b/core/res/res/layout/contact_header_name.xml index 9039702..9a56fb4 100644 --- a/core/res/res/layout/contact_header_name.xml +++ b/core/res/res/layout/contact_header_name.xml @@ -19,8 +19,8 @@ android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMediumInverse" - android:textColor="@android:color/secondary_text_light" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textStyle="bold" android:singleLine="true" android:ellipsize="end" /> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 6461460..6a3538d 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -28,4 +28,10 @@ <dimen name="toast_y_offset">64dip</dimen> <!-- Height of the status bar --> <dimen name="status_bar_height">25dip</dimen> + <!-- Size of the fastscroll hint letter --> + <dimen name="fastscroll_overlay_size">104dp</dimen> + <!-- Width of the fastscroll thumb --> + <dimen name="fastscroll_thumb_width">64dp</dimen> + <!-- Height of the fastscroll thumb --> + <dimen name="fastscroll_thumb_height">52dp</dimen> </resources> diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs index 11f8c7b..0b33739 100644 --- a/docs/html/guide/guide_toc.cs +++ b/docs/html/guide/guide_toc.cs @@ -139,6 +139,7 @@ <li><a href="<?cs var:toroot ?>guide/topics/manifest/intent-filter-element.html"><intent-filter></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/manifest-element.html"><manifest></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/meta-data-element.html"><meta-data></a></li> + <li><a href="<?cs var:toroot ?>guide/topics/manifest/path-permission-element.html"><path-permission></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-element.html"><permission></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-group-element.html"><permission-group></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-tree-element.html"><permission-tree></a></li> diff --git a/docs/html/guide/topics/manifest/manifest-intro.jd b/docs/html/guide/topics/manifest/manifest-intro.jd index 9e1b18d..89171c1 100644 --- a/docs/html/guide/topics/manifest/manifest-intro.jd +++ b/docs/html/guide/topics/manifest/manifest-intro.jd @@ -112,6 +112,7 @@ other mention of the element name. <a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a> <a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission /></a> + <a href="{@docRoot}guide/topics/manifest/path-permission-element.html"><path-permission /></a> <a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data /></a> <a href="{@docRoot}guide/topics/manifest/provider-element.html"></provider></a> @@ -140,6 +141,7 @@ add your own elements or attributes. <br/><code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data></a></code> +<br/><code><a href="{@docRoot}guide/topics/manifest/path-permission-element.html"><path-permission /></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/permission-group-element.html"><permission-group></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/permission-tree-element.html"><permission-tree></a></code> diff --git a/docs/html/guide/topics/manifest/path-permission-element.jd b/docs/html/guide/topics/manifest/path-permission-element.jd new file mode 100644 index 0000000..5c271a7 --- /dev/null +++ b/docs/html/guide/topics/manifest/path-permission-element.jd @@ -0,0 +1,104 @@ +page.title=<path-permission> +@jd:body + +<dl class="xml"> +<dt>syntax:</dt> +<dd><pre class="stx"> +<path-permission android:<a href="#path">path</a>="<i>string</i>" + android:<a href="#pathPrefix">pathPrefix</a>="<i>string</i>" + android:<a href="#pathPattern">pathPattern</a>="<i>string</i>" + android:<a href="#permission">permission</a>="<i>string</i>" + android:<a href="#readPermission">readPermission</a>="<i>string</i>" + android:<a href="#writePermission">writePermission</a>="<i>string</i>" /> +</pre></dd> + +<dt>contained in:</dt> +<dd><code><a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a></code></dd> + +<!-- +<dt>can contain:</dt> +</dd> +--> + +<dt>description:</dt> +<dd>Defines the path and required permissions for a specific subset of data +within a content provider. This element can be +specified multiple times to supply multiple paths. + +</dd> + +<dt>attributes:</dt> + +<dd><dl class="attr"> +<dt><a name="path"></a>{@code android:path}</dt> +<dd>A complete URI path for a subset of content provider data. +Permission can be granted only to the particular data identified by this path. +When used to provide search suggestion content, it must be appended +with "/search_suggest_query". +</dd> + +<dt><a name="pathPrefix"></a>{@code android:pathPrefix}</dt> +<dd>The initial part of a URI path for a subset of content provider data. +Permission can be granted to all data subsets with paths that share this initial part. +</dd> + +<dt><a name="pathPattern"></a>{@code android:pathPattern}</dt> +<dd>A complete URI path for a subset of content provider data, +but one that can use the following wildcards: + +<ul> +<li>An asterisk ('<code class="Code prettyprint">*</code>'). This matches a sequence of 0 to many occurrences of +the immediately preceding character.</li> + +<li>A period followed by an asterisk ("<code class="Code prettyprint">.*</code>"). This matches any sequence of +0 or more characters.</li> +</ul> + +<p> +Because '<code class="Code prettyprint">\</code>' is used as an escape character when the string is read +from XML (before it is parsed as a pattern), you will need to double-escape. +For example, a literal '<code class="Code prettyprint">*</code>' would be written as "<code class="Code prettyprint">\\*</code>" and a +literal '<code class="Code prettyprint">\</code>' would be written as "<code class="Code prettyprint">\\</code>". This is basically +the same as what you would need to write if constructing the string in Java code. +</p> +<p> +For more information on these types of patterns, see the descriptions of +<a href="/reference/android/os/PatternMatcher.html#PATTERN_LITERAL">PATTERN_LITERAL</a>, +<a href="/reference/android/os/PatternMatcher.html#PATTERN_PREFIX">PATTERN_PREFIX</a>, and +<a href="/reference/android/os/PatternMatcher.html#PATTERN_SIMPLE_GLOB">PATTERN_SIMPLE_GLOB</a> in the +<a href="/reference/android/os/PatternMatcher.html">PatternMatcher</a> class. +</p> +</dd> + +<dt><a name="permission"></a>{@code android:permission}</dt> +<dd>The name of a permission that clients must have in order to read or write the +content provider's data. This attribute is a convenient way of setting a +single permission for both reading and writing. However, the +<code>readPermission</code> and +<code>writePermission</code> attributes take precedence +over this one. +</dd> + +<dt><a name="readPermission"></a>{@code android:readPermission}</dt> +<dd>A permission that clients must have in order to query the content provider. +</dd> + +<dt><a name="writePermission"></a>{@code android:writePermission}</dt> +<dd>A permission that clients must have in order to make changes to the data controlled by the content provider. +</dd> + + + +</dl></dd> + +<!-- ##api level indication## --> +<dt>introduced in:</dt> +<dd>API Level 4</dd> + +<dt>see also:</dt> +<dd>{@link android.app.SearchManager}</dd> +<dd>{@link android.Manifest.permission}</dd> +<dd><a href="/guide/topics/security/security.html">Security and +Permissions</a></dd> + +</dl> diff --git a/docs/html/guide/topics/manifest/provider-element.jd b/docs/html/guide/topics/manifest/provider-element.jd index 2bb4ff4..3942f95 100644 --- a/docs/html/guide/topics/manifest/provider-element.jd +++ b/docs/html/guide/topics/manifest/provider-element.jd @@ -25,7 +25,9 @@ page.title=<provider> <dt>can contain:</dt> <dd><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data></a></code> -<br/><code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code></dd> +<br/><code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> +<br/><code><a href="{@docRoot}guide/topics/manifest/path-permission-element.html"><path-permission /></a></code> +</dd> <dt>description:</dt> <dd>Declares a content provider — a subclass of diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java index 3f75069..aeec739 100644 --- a/graphics/java/android/renderscript/Element.java +++ b/graphics/java/android/renderscript/Element.java @@ -111,7 +111,8 @@ public class Element extends BaseObj { NX (15), NY (16), NZ (17), - INDEX (18); + INDEX (18), + POINT_SIZE(19); int mID; DataKind(int id) { @@ -241,13 +242,18 @@ public class Element extends BaseObj { add(DataType.FLOAT, DataKind.Z, false, 32, null); return this; } - + public Builder addFloatST() { add(DataType.FLOAT, DataKind.S, false, 32, null); add(DataType.FLOAT, DataKind.T, false, 32, null); return this; } + public Builder addFloatPointSize() { + add(DataType.FLOAT, DataKind.POINT_SIZE, false, 32, null); + return this; + } + public Builder addFloatRGB() { add(DataType.FLOAT, DataKind.RED, false, 32, null); add(DataType.FLOAT, DataKind.GREEN, false, 32, null); diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java index aad09f6..392d93d 100644 --- a/graphics/java/android/renderscript/ProgramFragment.java +++ b/graphics/java/android/renderscript/ProgramFragment.java @@ -68,6 +68,7 @@ public class ProgramFragment extends BaseObj { RenderScript mRS; Element mIn; Element mOut; + boolean mPointSpriteEnable; private class Slot { Type mType; @@ -85,6 +86,7 @@ public class ProgramFragment extends BaseObj { mIn = in; mOut = out; mSlots = new Slot[MAX_SLOT]; + mPointSpriteEnable = false; for(int ct=0; ct < MAX_SLOT; ct++) { mSlots[ct] = new Slot(); } @@ -117,6 +119,9 @@ public class ProgramFragment extends BaseObj { mSlots[slot].mEnv = env; } + public void setPointSpriteTexCoordinateReplacement(boolean enable) { + mPointSpriteEnable = enable; + } static synchronized ProgramFragment internalCreate(RenderScript rs, Builder b) { int inID = 0; @@ -127,21 +132,18 @@ public class ProgramFragment extends BaseObj { if (b.mOut != null) { outID = b.mOut.mID; } - rs.nProgramFragmentBegin(inID, outID); + rs.nProgramFragmentBegin(inID, outID, b.mPointSpriteEnable); for(int ct=0; ct < MAX_SLOT; ct++) { if(b.mSlots[ct].mTexEnable) { Slot s = b.mSlots[ct]; + int typeID = 0; if(s.mType != null) { - rs.nProgramFragmentSetType(ct, s.mType.mID); - } - rs.nProgramFragmentSetTexEnable(ct, true); - if(s.mEnv != null) { - rs.nProgramFragmentSetEnvMode(ct, s.mEnv.mID); + typeID = s.mType.mID; } + rs.nProgramFragmentSetSlot(ct, true, s.mEnv.mID, typeID); } } - int id = rs.nProgramFragmentCreate(); return new ProgramFragment(id, rs); } diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index fca1c7a..1bdabe7 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -158,12 +158,10 @@ public class RenderScript { native void nProgramFragmentStoreDither(boolean enable); native int nProgramFragmentStoreCreate(); - native void nProgramFragmentBegin(int in, int out); + native void nProgramFragmentBegin(int in, int out, boolean pointSpriteEnable); native void nProgramFragmentBindTexture(int vpf, int slot, int a); native void nProgramFragmentBindSampler(int vpf, int slot, int s); - native void nProgramFragmentSetType(int slot, int vt); - native void nProgramFragmentSetEnvMode(int slot, int env); - native void nProgramFragmentSetTexEnable(int slot, boolean enable); + native void nProgramFragmentSetSlot(int slot, boolean enable, int env, int vt); native int nProgramFragmentCreate(); native void nProgramVertexBindAllocation(int pv, int mID); @@ -283,7 +281,11 @@ public class RenderScript { // Root state public void contextBindRootScript(Script s) { - nContextBindRootScript(s.mID); + int id = 0; + if(s != null) { + id = s.mID; + } + nContextBindRootScript(id); } //public void contextBindSampler(Sampler s, int slot) { diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 001ecd0..fede0e5 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -952,11 +952,11 @@ nProgramFragmentStoreCreate(JNIEnv *_env, jobject _this) // --------------------------------------------------------------------------- static void -nProgramFragmentBegin(JNIEnv *_env, jobject _this, jint in, jint out) +nProgramFragmentBegin(JNIEnv *_env, jobject _this, jint in, jint out, jboolean pointSpriteEnable) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentBegin, con(%p), in(%p), out(%p)", con, (RsElement)in, (RsElement)out); - rsProgramFragmentBegin(con, (RsElement)in, (RsElement)out); + LOG_API("nProgramFragmentBegin, con(%p), in(%p), out(%p) PointSprite(%i)", con, (RsElement)in, (RsElement)out, pointSpriteEnable); + rsProgramFragmentBegin(con, (RsElement)in, (RsElement)out, pointSpriteEnable); } static void @@ -976,27 +976,11 @@ nProgramFragmentBindSampler(JNIEnv *_env, jobject _this, jint vpf, jint slot, ji } static void -nProgramFragmentSetType(JNIEnv *_env, jobject _this, jint slot, jint vt) +nProgramFragmentSetSlot(JNIEnv *_env, jobject _this, jint slot, jboolean enable, jint env, jint vt) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentSetType, con(%p), slot(%i), vt(%p)", con, slot, (RsType)vt); - rsProgramFragmentSetType(con, slot, (RsType)vt); -} - -static void -nProgramFragmentSetEnvMode(JNIEnv *_env, jobject _this, jint slot, jint env) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentSetEnvMode, con(%p), slot(%i), vt(%i)", con, slot, env); - rsProgramFragmentSetEnvMode(con, slot, (RsTexEnvMode)env); -} - -static void -nProgramFragmentSetTexEnable(JNIEnv *_env, jobject _this, jint slot, jboolean enable) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentSetTexEnable, con(%p), slot(%i), enable(%i)", con, slot, enable); - rsProgramFragmentSetTexEnable(con, slot, enable); + LOG_API("nProgramFragmentSetType, con(%p), slot(%i), enable(%i), env(%i), vt(%p)", con, slot, enable, env, (RsType)vt); + rsProgramFragmentSetSlot(con, slot, enable, (RsTexEnvMode)env, (RsType)vt); } static jint @@ -1305,12 +1289,10 @@ static JNINativeMethod methods[] = { {"nProgramFragmentStoreDither", "(Z)V", (void*)nProgramFragmentStoreDither }, {"nProgramFragmentStoreCreate", "()I", (void*)nProgramFragmentStoreCreate }, -{"nProgramFragmentBegin", "(II)V", (void*)nProgramFragmentBegin }, +{"nProgramFragmentBegin", "(IIZ)V", (void*)nProgramFragmentBegin }, {"nProgramFragmentBindTexture", "(III)V", (void*)nProgramFragmentBindTexture }, {"nProgramFragmentBindSampler", "(III)V", (void*)nProgramFragmentBindSampler }, -{"nProgramFragmentSetType", "(II)V", (void*)nProgramFragmentSetType }, -{"nProgramFragmentSetEnvMode", "(II)V", (void*)nProgramFragmentSetEnvMode }, -{"nProgramFragmentSetTexEnable", "(IZ)V", (void*)nProgramFragmentSetTexEnable }, +{"nProgramFragmentSetSlot", "(IZII)V", (void*)nProgramFragmentSetSlot }, {"nProgramFragmentCreate", "()I", (void*)nProgramFragmentCreate }, {"nProgramVertexBindAllocation", "(II)V", (void*)nProgramVertexBindAllocation }, diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index e4cf00f..2f60c9f 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -80,7 +80,8 @@ enum RsDataKind { RS_KIND_NX, RS_KIND_NY, RS_KIND_NZ, - RS_KIND_INDEX + RS_KIND_INDEX, + RS_KIND_POINT_SIZE }; enum RsElementPredefined { diff --git a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java index c6f5816..fae92f7 100644 --- a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java +++ b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java @@ -115,7 +115,7 @@ class GalaxyRS { loadTextures(); ScriptC.Builder sb = new ScriptC.Builder(mRS); - sb.setType(mStateType, "State", 0); + sb.setType(mStateType, "State", RSID_STATE); sb.setScript(mResources, R.raw.galaxy); sb.setRoot(true); diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 1a81021..e275f27 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -361,6 +361,7 @@ ProgramFragmentStoreCreate { ProgramFragmentBegin { param RsElement in param RsElement out + param bool pointSpriteEnable } ProgramFragmentBindTexture { @@ -375,19 +376,11 @@ ProgramFragmentBindSampler { param RsSampler s } -ProgramFragmentSetType { - param uint32_t slot - param RsType t - } - -ProgramFragmentSetEnvMode { - param uint32_t slot - param RsTexEnvMode env - } - -ProgramFragmentSetTexEnable { +ProgramFragmentSetSlot { param uint32_t slot param bool enable + param RsTexEnvMode env + param RsType t } ProgramFragmentCreate { diff --git a/libs/rs/rsComponent.cpp b/libs/rs/rsComponent.cpp index b88710c..4a043f3 100644 --- a/libs/rs/rsComponent.cpp +++ b/libs/rs/rsComponent.cpp @@ -24,7 +24,7 @@ using namespace android::renderscript; Component::Component() { mType = FLOAT; - mKind = NONE; + mKind = USER; mIsNormalized = false; mBits = 0; } diff --git a/libs/rs/rsComponent.h b/libs/rs/rsComponent.h index 6342f1b..5856524 100644 --- a/libs/rs/rsComponent.h +++ b/libs/rs/rsComponent.h @@ -34,13 +34,13 @@ public: }; enum DataKind { - NONE, + USER, RED, GREEN, BLUE, ALPHA, LUMINANCE, INTENSITY, X, Y, Z, W, S, T, Q, R, NX, NY, NZ, INDEX, - USER + POINT_SIZE }; diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index 9df07bf..4ef6835 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -24,7 +24,7 @@ using namespace android; using namespace android::renderscript; -ProgramFragment::ProgramFragment(Element *in, Element *out) : +ProgramFragment::ProgramFragment(Element *in, Element *out, bool pointSpriteEnable) : Program(in, out) { for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) { @@ -32,6 +32,7 @@ ProgramFragment::ProgramFragment(Element *in, Element *out) : mTextureDimensions[ct] = 2; } mTextureEnableMask = 0; + mPointSpriteEnable = pointSpriteEnable; mEnvModes[1] = RS_TEX_ENV_MODE_DECAL; } @@ -54,6 +55,7 @@ void ProgramFragment::setupGL(ProgramFragmentState *state) } glEnable(GL_TEXTURE_2D); + //glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, mPointSpriteEnable); glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID()); switch(mEnvModes[ct]) { @@ -94,7 +96,6 @@ void ProgramFragment::setupGL(ProgramFragmentState *state) glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); } } - glActiveTexture(GL_TEXTURE0); mDirty = false; } @@ -178,7 +179,7 @@ ProgramFragmentState::~ProgramFragmentState() void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h) { - ProgramFragment *pf = new ProgramFragment(NULL, NULL); + ProgramFragment *pf = new ProgramFragment(NULL, NULL, false); mDefault.set(pf); } @@ -186,10 +187,10 @@ void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h) namespace android { namespace renderscript { -void rsi_ProgramFragmentBegin(Context * rsc, RsElement in, RsElement out) +void rsi_ProgramFragmentBegin(Context * rsc, RsElement in, RsElement out, bool pointSpriteEnable) { delete rsc->mStateFragment.mPF; - rsc->mStateFragment.mPF = new ProgramFragment((Element *)in, (Element *)out); + rsc->mStateFragment.mPF = new ProgramFragment((Element *)in, (Element *)out, pointSpriteEnable); } void rsi_ProgramFragmentBindTexture(Context *rsc, RsProgramFragment vpf, uint32_t slot, RsAllocation a) @@ -204,27 +205,20 @@ void rsi_ProgramFragmentBindSampler(Context *rsc, RsProgramFragment vpf, uint32_ pf->bindSampler(slot, static_cast<Sampler *>(s)); } -void rsi_ProgramFragmentSetType(Context *rsc, uint32_t slot, RsType vt) +void rsi_ProgramFragmentSetSlot(Context *rsc, uint32_t slot, bool enable, RsTexEnvMode env, RsType vt) { const Type *t = static_cast<const Type *>(vt); - uint32_t dim = 1; - if (t->getDimY()) { - dim ++; - if (t->getDimZ()) { + if (t) { + uint32_t dim = 1; + if (t->getDimY()) { dim ++; + if (t->getDimZ()) { + dim ++; + } } + rsc->mStateFragment.mPF->setType(slot, t->getElement(), dim); } - - rsc->mStateFragment.mPF->setType(slot, t->getElement(), dim); -} - -void rsi_ProgramFragmentSetEnvMode(Context *rsc, uint32_t slot, RsTexEnvMode env) -{ rsc->mStateFragment.mPF->setEnvMode(slot, env); -} - -void rsi_ProgramFragmentSetTexEnable(Context *rsc, uint32_t slot, bool enable) -{ rsc->mStateFragment.mPF->setTexEnable(slot, enable); } diff --git a/libs/rs/rsProgramFragment.h b/libs/rs/rsProgramFragment.h index 57fb6a5..bd45342 100644 --- a/libs/rs/rsProgramFragment.h +++ b/libs/rs/rsProgramFragment.h @@ -32,7 +32,7 @@ public: - ProgramFragment(Element *in, Element *out); + ProgramFragment(Element *in, Element *out, bool pointSpriteEnable); virtual ~ProgramFragment(); virtual void setupGL(ProgramFragmentState *); @@ -64,6 +64,7 @@ protected: // Hacks to create a program for now RsTexEnvMode mEnvModes[MAX_TEXTURE]; uint32_t mTextureEnableMask; + bool mPointSpriteEnable; }; class ProgramFragmentState diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp index c14c371..332d532 100644 --- a/libs/rs/rsSampler.cpp +++ b/libs/rs/rsSampler.cpp @@ -143,6 +143,7 @@ RsSampler rsi_SamplerCreate(Context *rsc) ss->mWrapS, ss->mWrapT, ss->mWrapR); + s->incRef(); return s; } diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp index 5f8ee2a..84a39aa 100644 --- a/libs/rs/rsScriptC_Lib.cpp +++ b/libs/rs/rsScriptC_Lib.cpp @@ -729,7 +729,7 @@ static void SC_shininess(float s) glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, s); } -static void SC_hsb(float h, float s, float b, float a) +static void SC_hsbToRgb(float h, float s, float b, float* rgb) { float red = 0.0f; float green = 0.0f; @@ -779,7 +779,26 @@ static void SC_hsb(float h, float s, float b, float a) break; } - glColor4f(red, green, blue, a); + rgb[0] = red; + rgb[1] = green; + rgb[2] = blue; +} + +static int SC_hsbToAbgr(float h, float s, float b, float a) +{ + float rgb[3]; + SC_hsbToRgb(h, s, b, rgb); + return int(a * 255.0f) << 24 | + int(rgb[2] * 255.0f) << 16 | + int(rgb[1] * 255.0f) << 8 | + int(rgb[0] * 255.0f); +} + +static void SC_hsb(float h, float s, float b, float a) +{ + float rgb[3]; + SC_hsbToRgb(h, s, b, rgb); + glColor4f(rgb[0], rgb[1], rgb[2], a); } static void SC_uploadToTexture(RsAllocation va, uint32_t baseMipLevel) @@ -809,11 +828,21 @@ static void SC_debugF(const char *s, float f) LOGE("%s %f", s, f); } +static void SC_debugHexF(const char *s, float f) +{ + LOGE("%s 0x%x", s, *((int *) (&f))); +} + static void SC_debugI32(const char *s, int32_t i) { LOGE("%s %i", s, i); } +static void SC_debugHexI32(const char *s, int32_t i) +{ + LOGE("%s 0x%x", s, i); +} + static uint32_t SC_getWidth() { GET_TLS(); @@ -1055,6 +1084,10 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = { "void", "(float, float, float, float)" }, { "hsb", (void *)&SC_hsb, "void", "(float, float, float, float)" }, + { "hsbToRgb", (void *)&SC_hsbToRgb, + "void", "(float, float, float, float*)" }, + { "hsbToAbgr", (void *)&SC_hsbToAbgr, + "int", "(float, float, float, float)" }, { "ambient", (void *)&SC_ambient, "void", "(float, float, float, float)" }, { "diffuse", (void *)&SC_diffuse, @@ -1088,6 +1121,10 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = { "void", "(void *, float)" }, { "debugI32", (void *)&SC_debugI32, "void", "(void *, int)" }, + { "debugHexF", (void *)&SC_debugHexF, + "void", "(void *, float)" }, + { "debugHexI32", (void *)&SC_debugHexI32, + "void", "(void *, int)" }, { NULL, NULL, NULL, NULL } diff --git a/libs/rs/rsTriangleMesh.cpp b/libs/rs/rsTriangleMesh.cpp index 8c7bc92..99f8adb 100644 --- a/libs/rs/rsTriangleMesh.cpp +++ b/libs/rs/rsTriangleMesh.cpp @@ -199,6 +199,7 @@ RsTriangleMesh rsi_TriangleMeshCreate(Context *rsc) memcpy(tm->mIndexData, tmc->mIndexData.array(), tm->mIndexDataSize); tm->analyzeElement(); + tm->incRef(); return tm; } @@ -248,16 +249,16 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tm->mBufferObjects[1]); glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(tm->mSizeCoord, - GL_FLOAT, - tm->mVertexElement->getSizeBytes(), + glVertexPointer(tm->mSizeCoord, + GL_FLOAT, + tm->mVertexElement->getSizeBytes(), (void *)tm->mVertexElement->getComponentOffsetBytes(tm->mOffsetCoord)); if (tm->mSizeTex) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(tm->mSizeTex, - GL_FLOAT, - tm->mVertexElement->getSizeBytes(), + glTexCoordPointer(tm->mSizeTex, + GL_FLOAT, + tm->mVertexElement->getSizeBytes(), (void *)tm->mVertexElement->getComponentOffsetBytes(tm->mOffsetTex)); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -265,8 +266,8 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs if (tm->mSizeNorm) { glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, - tm->mVertexElement->getSizeBytes(), + glNormalPointer(GL_FLOAT, + tm->mVertexElement->getSizeBytes(), (void *)tm->mVertexElement->getComponentOffsetBytes(tm->mOffsetNorm)); } else { glDisableClientState(GL_NORMAL_ARRAY); diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp index a40a152..5a9090e 100644 --- a/libs/rs/rsType.cpp +++ b/libs/rs/rsType.cpp @@ -230,6 +230,13 @@ void Type::makeGLComponents() mGL.mTex[texNum].size = 4; break; + case Component::POINT_SIZE: + rsAssert(!mGL.mPointSize.size); + mGL.mPointSize.size = 1; + mGL.mPointSize.offset = mElement->getComponentOffsetBytes(ct); + mGL.mPointSize.type = c->getGLType(); + break; + default: break; } @@ -280,6 +287,13 @@ void Type::enableGLVertexBuffer() const } glClientActiveTexture(GL_TEXTURE0); + if (mGL.mPointSize.size) { + glEnableClientState(GL_POINT_SIZE_ARRAY_OES); + glPointSizePointerOES(mGL.mPointSize.type, + stride, + (void *)mGL.mPointSize.offset); + } + } diff --git a/libs/rs/rsType.h b/libs/rs/rsType.h index 60d75d7..6c39a4c 100644 --- a/libs/rs/rsType.h +++ b/libs/rs/rsType.h @@ -118,6 +118,7 @@ protected: VertexComponent_t mNorm; VertexComponent_t mColor; VertexComponent_t mTex[RS_MAX_TEXTURE]; + VertexComponent_t mPointSize; }; GLState_t mGL; void makeGLComponents(); diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java index 132473a..022da0c 100644 --- a/opengl/java/android/opengl/GLSurfaceView.java +++ b/opengl/java/android/opengl/GLSurfaceView.java @@ -655,25 +655,27 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback EGLConfig closestConfig = null; int closestDistance = 1000; for(EGLConfig config : configs) { - int r = findConfigAttrib(egl, display, config, - EGL10.EGL_RED_SIZE, 0); - int g = findConfigAttrib(egl, display, config, - EGL10.EGL_GREEN_SIZE, 0); - int b = findConfigAttrib(egl, display, config, - EGL10.EGL_BLUE_SIZE, 0); - int a = findConfigAttrib(egl, display, config, - EGL10.EGL_ALPHA_SIZE, 0); int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0); int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0); - int distance = Math.abs(r - mRedSize) - + Math.abs(g - mGreenSize) - + Math.abs(b - mBlueSize) + Math.abs(a - mAlphaSize) - + Math.abs(d - mDepthSize) + Math.abs(s - mStencilSize); - if (distance < closestDistance) { - closestDistance = distance; - closestConfig = config; + if (d >= mDepthSize && s>= mStencilSize) { + int r = findConfigAttrib(egl, display, config, + EGL10.EGL_RED_SIZE, 0); + int g = findConfigAttrib(egl, display, config, + EGL10.EGL_GREEN_SIZE, 0); + int b = findConfigAttrib(egl, display, config, + EGL10.EGL_BLUE_SIZE, 0); + int a = findConfigAttrib(egl, display, config, + EGL10.EGL_ALPHA_SIZE, 0); + int distance = Math.abs(r - mRedSize) + + Math.abs(g - mGreenSize) + + Math.abs(b - mBlueSize) + + Math.abs(a - mAlphaSize); + if (distance < closestDistance) { + closestDistance = distance; + closestConfig = config; + } } } return closestConfig; diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp index 445e681..d51b333 100644 --- a/opengl/libs/EGL/Loader.cpp +++ b/opengl/libs/EGL/Loader.cpp @@ -224,12 +224,12 @@ void Loader::init_api(void* dso, void *Loader::load_driver(const char* driver, gl_hooks_t* hooks, uint32_t mask) { - //LOGD("%s", driver); void* dso = dlopen(driver, RTLD_NOW | RTLD_LOCAL); - LOGE_IF(!dso, "%s", dlerror()); if (dso == 0) return 0; + LOGD("loaded %s", driver); + if (mask & EGL) { getProcAddress = (getProcAddressType)dlsym(dso, "eglGetProcAddress"); diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java index 07bab18..3c62aa0 100644 --- a/services/java/com/android/server/WallpaperManagerService.java +++ b/services/java/com/android/server/WallpaperManagerService.java @@ -404,7 +404,9 @@ class WallpaperManagerService extends IWallpaperManager.Stub { void attachServiceLocked(WallpaperConnection conn) { try { - conn.mService.attach(conn, conn.mToken, mWidth, mHeight); + conn.mService.attach(conn, conn.mToken, + WindowManager.LayoutParams.TYPE_WALLPAPER, false, + mWidth, mHeight); } catch (RemoteException e) { Log.w(TAG, "Failed attaching wallpaper; clearing", e); bindWallpaperComponentLocked(null); diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 7ca8b52..f8ba058 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -405,7 +405,12 @@ public class WindowManagerService extends IWindowManager.Stub // If non-null, this is the currently visible window that is associated // with the wallpaper. WindowState mWallpaperTarget = null; - WindowState mUpcomingWallpaperTarget = null; + // If non-null, we are in the middle of animating from one wallpaper target + // to another, and this is the lower one in Z-order. + WindowState mLowerWallpaperTarget = null; + // If non-null, we are in the middle of animating from one wallpaper target + // to another, and this is the higher one in Z-order. + WindowState mUpperWallpaperTarget = null; int mWallpaperAnimLayerAdjustment; AppWindowToken mFocusedApp = null; @@ -1179,7 +1184,8 @@ public class WindowManagerService extends IWindowManager.Stub boolean adjustWallpaperWindowsLocked() { boolean changed = false; - mUpcomingWallpaperTarget = null; + final int dw = mDisplay.getWidth(); + final int dh = mDisplay.getHeight(); // First find top-most window that has asked to be on top of the // wallpaper; all wallpapers go behind it. @@ -1188,60 +1194,41 @@ public class WindowManagerService extends IWindowManager.Stub WindowState w = null; WindowState foundW = null; int foundI = 0; - AppWindowToken topToken = null; - AppWindowToken behindToken = null; int i = N; while (i > 0) { i--; w = (WindowState)localmWindows.get(i); - if (topToken != null) { - if (w.mAppToken == topToken) { + if (w.mAppToken != null) { + // If this window's app token is hidden and not animating, + // it is of no interest to us. + if (w.mAppToken.hidden && w.mAppToken.animation == null) { + if (DEBUG_WALLPAPER) Log.v(TAG, + "Skipping hidden or animating token: " + w); continue; } - if (w.mAppToken != null) { - if (behindToken == null) { - // We need to look through for what is behind the - // potential new wallpaper target... skip all tokens - // that are hidden and not animating, since they can't - // be involved with the transition. - if (w.mAppToken.hidden && w.mAppToken.animation == null) { - continue; - } - behindToken = w.mAppToken; - } - if (w.mAppToken != behindToken) { - break; - } + // If this window's app token is ot fullscreen, also irrelevant. + if (!w.mAppToken.appFullscreen) { + if (DEBUG_WALLPAPER) Log.v(TAG, + "Skipping non-fullscreen token: " + w); + continue; } } + if (DEBUG_WALLPAPER) Log.v(TAG, "Win " + w + ": readyfordisplay=" + + w.isReadyForDisplay() + " drawpending=" + w.mDrawPending + + " commitdrawpending=" + w.mCommitDrawPending); if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0 && w.isReadyForDisplay() && !w.mDrawPending && !w.mCommitDrawPending) { - if (behindToken != null && w.mAppToken == behindToken) { - // We had previously found a wallpaper window that was - // animating, and now we found one behind it. We could - // be doing an animation between two windows on top of - // the wallpaper! - if (mWallpaperTarget == w || mWallpaperTarget == foundW) { - // Retain the current wallpaper target (don't move - // the wallpaper yet), but note the window that is - // going to become the wallpaper target so that - // others know about this special state. - if (DEBUG_WALLPAPER) Log.v(TAG, - "Switching wallpaper activities: cur#" + i + "=" - + w + " upcoming#" + foundI + "=" + foundW); - mUpcomingWallpaperTarget = foundW; - foundW = w; - foundI = i; - break; - } - } + if (DEBUG_WALLPAPER) Log.v(TAG, + "Found wallpaper activity: #" + i + "=" + w); foundW = w; foundI = i; - if (w.mAppToken != null && w.mAppToken.animation != null) { - // If this app token is animating, we want to keep the - // wallpaper below it if it is animating on top of another - // app with a wallpaper. - topToken = w.mAppToken; + if (w == mWallpaperTarget && w.mAppToken != null + && w.mAppToken.animation != null) { + // The current wallpaper target is animating, so we'll + // look behind it for another possible target and figure + // out what is going on below. + if (DEBUG_WALLPAPER) Log.v(TAG, "Win " + w + + ": token animating, looking behind."); continue; } break; @@ -1258,20 +1245,93 @@ public class WindowManagerService extends IWindowManager.Stub // enough (we'll just wait until whatever transition is pending // executes). if (mWallpaperTarget != null && mWallpaperTarget.mAppToken != null) { + if (DEBUG_WALLPAPER) Log.v(TAG, + "Wallpaper not changing: waiting for app anim in current target"); return false; } if (foundW != null && foundW.mAppToken != null) { - return false; - } - if (mUpcomingWallpaperTarget != null && mUpcomingWallpaperTarget.mAppToken != null) { + if (DEBUG_WALLPAPER) Log.v(TAG, + "Wallpaper not changing: waiting for app anim in found target"); return false; } } if (mWallpaperTarget != foundW) { - mWallpaperTarget = foundW; if (DEBUG_WALLPAPER) { - Log.v(TAG, "New wallpaper target: " + foundW); + Log.v(TAG, "New wallpaper target: " + foundW + + " oldTarget: " + mWallpaperTarget); + } + + mLowerWallpaperTarget = null; + mUpperWallpaperTarget = null; + + WindowState oldW = mWallpaperTarget; + mWallpaperTarget = foundW; + + // Now what is happening... if the current and new targets are + // animating, then we are in our super special mode! + if (foundW != null && foundW.mAppToken != null && oldW != null + && oldW.mAppToken != null) { + if (DEBUG_WALLPAPER) { + Log.v(TAG, "New animation: " + foundW.mAppToken.animation + + " old animation: " + oldW.mAppToken.animation); + } + if (foundW.mAppToken.animation != null + && oldW.mAppToken.animation != null) { + int oldI = localmWindows.indexOf(oldW); + if (DEBUG_WALLPAPER) { + Log.v(TAG, "New i: " + foundI + " old i: " + oldI); + } + if (oldI >= 0) { + if (DEBUG_WALLPAPER) { + Log.v(TAG, "Animating wallpapers: old#" + oldI + + "=" + oldW + "; new#" + foundI + + "=" + foundW); + } + + // Set the new target correctly. + if (foundW.mAppToken.hiddenRequested) { + if (DEBUG_WALLPAPER) { + Log.v(TAG, "Old wallpaper still the target."); + } + mWallpaperTarget = oldW; + } + + // Now set the upper and lower wallpaper targets + // correctly, and make sure that we are positioning + // the wallpaper below the lower. + if (foundI > oldI) { + // The new target is on top of the old one. + if (DEBUG_WALLPAPER) { + Log.v(TAG, "Found target above old target."); + } + mUpperWallpaperTarget = foundW; + mLowerWallpaperTarget = oldW; + foundW = oldW; + foundI = oldI; + } else { + // The new target is below the old one. + if (DEBUG_WALLPAPER) { + Log.v(TAG, "Found target below old target."); + } + mUpperWallpaperTarget = oldW; + mLowerWallpaperTarget = foundW; + } + } + } + } + + } else { + // Is it time to stop animating? + if (mLowerWallpaperTarget == null + || mLowerWallpaperTarget.mAppToken.animation == null + || mUpperWallpaperTarget == null + || mUpperWallpaperTarget.mAppToken.animation == null) { + if (DEBUG_WALLPAPER) { + Log.v(TAG, "No longer animating wallpaper targets!"); + } + mLowerWallpaperTarget = null; + mUpperWallpaperTarget = null; } } @@ -1286,7 +1346,7 @@ public class WindowManagerService extends IWindowManager.Stub // its layer adjustment. Only do this if we are not transfering // between two wallpaper targets. mWallpaperAnimLayerAdjustment = - (mUpcomingWallpaperTarget == null && foundW.mAppToken != null) + (mLowerWallpaperTarget == null && foundW.mAppToken != null) ? foundW.mAppToken.animLayerAdjustment : 0; // Now w is the window we are supposed to be behind... but we @@ -1310,9 +1370,6 @@ public class WindowManagerService extends IWindowManager.Stub // what is below it for later. foundW = foundI > 0 ? (WindowState)localmWindows.get(foundI-1) : null; - final int dw = mDisplay.getWidth(); - final int dh = mDisplay.getHeight(); - // Start stepping backwards from here, ensuring that our wallpaper windows // are correctly placed. int curTokenIndex = mWallpaperTokens.size(); @@ -6676,11 +6733,14 @@ public class WindowManagerService extends IWindowManager.Stub mAppToken.startingDisplayed = false; } - if (localLOGV) Log.v( - TAG, "Window " + this - + " destroying surface " + mSurface + ", session " + mSession); if (mSurface != null) { try { + if (DEBUG_VISIBILITY) { + RuntimeException e = new RuntimeException(); + e.fillInStackTrace(); + Log.w(TAG, "Window " + this + " destroying surface " + + mSurface + ", session " + mSession, e); + } if (SHOW_TRANSACTIONS) { RuntimeException ex = new RuntimeException(); ex.fillInStackTrace(); @@ -6829,7 +6889,7 @@ public class WindowManagerService extends IWindowManager.Stub } mHasLocalTransformation = false; if ((!mLocalAnimating || mAnimationIsEntrance) && mAppToken != null - && mAppToken.hasTransformation) { + && mAppToken.animation != null) { // When our app token is animating, we kind-of pretend like // we are as well. Note the mLocalAnimating mAnimationIsEntrance // part of this check means that we will only do this if @@ -6962,7 +7022,7 @@ public class WindowManagerService extends IWindowManager.Stub // Wallpapers are animated based on the "real" window they // are currently targeting. - if (mAttrs.type == TYPE_WALLPAPER && mUpcomingWallpaperTarget == null + if (mAttrs.type == TYPE_WALLPAPER && mLowerWallpaperTarget == null && mWallpaperTarget != null) { if (mWallpaperTarget.mHasLocalTransformation) { attachedTransformation = mWallpaperTarget.mTransformation; @@ -7600,7 +7660,7 @@ public class WindowManagerService extends IWindowManager.Stub if (w == mInputMethodTarget) { setInputMethodAnimLayerAdjustment(adj); } - if (w == mWallpaperTarget && mUpcomingWallpaperTarget == null) { + if (w == mWallpaperTarget && mLowerWallpaperTarget == null) { setWallpaperAnimLayerAdjustmentLocked(adj); } } @@ -7640,7 +7700,7 @@ public class WindowManagerService extends IWindowManager.Stub if (animation == sDummyAnimation) { // This guy is going to animate, but not yet. For now count - // it is not animating for purposes of scheduling transactions; + // it as not animating for purposes of scheduling transactions; // when it is really time to animate, this will be set to // a real animation and the next call will execute normally. return false; @@ -7780,6 +7840,7 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows); } pw.print(prefix); pw.print("groupId="); pw.print(groupId); + pw.print(" appFullscreen="); pw.println(appFullscreen); pw.print(" requestedOrientation="); pw.println(requestedOrientation); pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested); pw.print(" clientHidden="); pw.print(clientHidden); @@ -8725,13 +8786,12 @@ public class WindowManagerService extends IWindowManager.Stub mH.removeMessages(H.APP_TRANSITION_TIMEOUT); - boolean wallpaperMoved = adjustWallpaperWindowsLocked(); + adjustWallpaperWindowsLocked(); if (DEBUG_APP_TRANSITIONS) Log.v(TAG, - "Old wallpaper target=" + mWallpaperTarget - + ", upcoming target=" + mUpcomingWallpaperTarget); - if (mUpcomingWallpaperTarget != mWallpaperTarget && - mUpcomingWallpaperTarget != null && - mWallpaperTarget != null) { + "New wallpaper target=" + mWallpaperTarget + + ", lower target=" + mLowerWallpaperTarget + + ", upper target=" + mUpperWallpaperTarget); + if (mLowerWallpaperTarget != null) { // Need to determine if both the closing and // opening app token sets are wallpaper targets, // in which case special animations are needed @@ -8741,20 +8801,20 @@ public class WindowManagerService extends IWindowManager.Stub NN = mOpeningApps.size(); for (i=0; i<NN; i++) { AppWindowToken wtoken = mOpeningApps.get(i); - if (mUpcomingWallpaperTarget.mAppToken == wtoken) { + if (mLowerWallpaperTarget.mAppToken == wtoken) { found |= 1; } - if (mWallpaperTarget.mAppToken == wtoken) { + if (mUpperWallpaperTarget.mAppToken == wtoken) { found |= 1; } } NN = mClosingApps.size(); for (i=0; i<NN; i++) { AppWindowToken wtoken = mClosingApps.get(i); - if (mUpcomingWallpaperTarget.mAppToken == wtoken) { + if (mLowerWallpaperTarget.mAppToken == wtoken) { found |= 2; } - if (mWallpaperTarget.mAppToken == wtoken) { + if (mUpperWallpaperTarget.mAppToken == wtoken) { found |= 2; } } diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java index cc981c9..e187c37 100644 --- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java @@ -99,6 +99,7 @@ public abstract class DataConnectionTracker extends Handler { protected static final int EVENT_PS_RESTRICT_DISABLED = 33; public static final int EVENT_CLEAN_UP_CONNECTION = 34; protected static final int EVENT_CDMA_OTA_PROVISION = 35; + protected static final int EVENT_RESTART_RADIO = 36; //***** Constants diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java index 7bbf91d..3b2c90c 100755..100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java @@ -294,8 +294,14 @@ public final class CdmaCallTracker extends CallTracker { // Should we bother with this check? if (ringingCall.getState() == CdmaCall.State.INCOMING) { throw new CallStateException("cannot be in the incoming state"); - } else { + } else if (foregroundCall.getConnections().size() > 1) { flashAndSetGenericTrue(); + } else { + // Send a flash command to CDMA network for putting the other party on hold. + // For CDMA networks which do not support this the user would just hear a beep + // from the network. For CDMA networks which do support it will put the other + // party on hold. + cm.sendCDMAFeatureCode("", obtainMessage(EVENT_SWITCH_RESULT)); } } diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java index 8913e81..2b78097 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java @@ -76,6 +76,10 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { /** Currently active CdmaDataConnection */ private CdmaDataConnection mActiveDataConnection; + private boolean mPendingRestartRadio = false; + private static final int TIME_DELAYED_TO_RESTART_RADIO = + SystemProperties.getInt("ro.cdma.timetoradiorestart", 20000); + /** * Pool size of CdmaDataConnection objects. */ @@ -318,7 +322,8 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { && (mCdmaPhone.mSST.isConcurrentVoiceAndData() || phone.getState() == Phone.State.IDLE ) && isDataAllowed() - && desiredPowerState) { + && desiredPowerState + && !mPendingRestartRadio) { return setupData(reason); @@ -334,7 +339,8 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { " dataEnabled=" + getAnyDataEnabled() + " roaming=" + roaming + " dataOnRoamingEnable=" + getDataOnRoamingEnabled() + - " desiredPowerState=" + desiredPowerState); + " desiredPowerState=" + desiredPowerState + + " PendingRestartRadio=" + mPendingRestartRadio); } return false; } @@ -445,16 +451,11 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { } protected void restartRadio() { - Log.d(LOG_TAG, "************TURN OFF RADIO**************"); - cleanUpConnection(true, Phone.REASON_CDMA_DATA_DETACHED); - phone.mCM.setRadioPower(false, null); - /* Note: no need to call setRadioPower(true). Assuming the desired - * radio power state is still ON (as tracked by ServiceStateTracker), - * ServiceStateTracker will call setRadioPower when it receives the - * RADIO_STATE_CHANGED notification for the power off. And if the - * desired power state has changed in the interim, we don't want to - * override it with an unconditional power on. - */ + if (DBG) log("Cleanup connection and wait " + + (TIME_DELAYED_TO_RESTART_RADIO / 1000) + "s to restart radio"); + cleanUpConnection(true, Phone.REASON_RADIO_TURNED_OFF); + sendEmptyMessageDelayed(EVENT_RESTART_RADIO, TIME_DELAYED_TO_RESTART_RADIO); + mPendingRestartRadio = true; } private Runnable mPollNetStat = new Runnable() { @@ -719,8 +720,18 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { } setState(State.IDLE); + // Since the pending request to turn off or restart radio will be processed here, + // remove the pending event to restart radio from the message queue. + if (mPendingRestartRadio) removeMessages(EVENT_RESTART_RADIO); + + // Process the pending request to turn off radio in ServiceStateTracker first. + // If radio is turned off in ServiceStateTracker, ignore the pending event to restart radio. CdmaServiceStateTracker ssTracker = mCdmaPhone.mSST; - ssTracker.processPendingRadioPowerOffAfterDataOff(); + if (ssTracker.processPendingRadioPowerOffAfterDataOff()) { + mPendingRestartRadio = false; + } else { + onRestartRadio(); + } phone.notifyDataConnection(reason); if (retryAfterDisconnected(reason)) { @@ -816,6 +827,21 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { } } + private void onRestartRadio() { + if (mPendingRestartRadio) { + Log.d(LOG_TAG, "************TURN OFF RADIO**************"); + phone.mCM.setRadioPower(false, null); + /* Note: no need to call setRadioPower(true). Assuming the desired + * radio power state is still ON (as tracked by ServiceStateTracker), + * ServiceStateTracker will call setRadioPower when it receives the + * RADIO_STATE_CHANGED notification for the power off. And if the + * desired power state has changed in the interim, we don't want to + * override it with an unconditional power on. + */ + mPendingRestartRadio = false; + } + } + private void writeEventLogCdmaDataDrop() { CdmaCellLocation loc = (CdmaCellLocation)(phone.getCellLocation()); int bsid = (loc != null) ? loc.getBaseStationId() : -1; @@ -928,6 +954,11 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { onCdmaOtaProvision((AsyncResult) msg.obj); break; + case EVENT_RESTART_RADIO: + if (DBG) log("EVENT_RESTART_RADIO"); + onRestartRadio(); + break; + default: // handle the message in the super class DataConnectionTracker super.handleMessage(msg); diff --git a/tests/DumpRenderTree/assets/run_layout_tests.py b/tests/DumpRenderTree/assets/run_layout_tests.py index 49165d0..c056de5 100755 --- a/tests/DumpRenderTree/assets/run_layout_tests.py +++ b/tests/DumpRenderTree/assets/run_layout_tests.py @@ -22,7 +22,7 @@ use --refresh-test-list option *once* to re-generate test list on the card. Some other options are: - --rebaseline generates expected layout tests results under /sdcard/android/expected_result/ + --rebaseline generates expected layout tests results under /sdcard/android/expected_result/ --time-out-ms (default is 8000 millis) for each test --adb-options="-e" passes option string to adb --results-directory=..., (default is ./layout-test-results) directory name under which results are stored. @@ -51,11 +51,11 @@ def CountLineNumber(filename): def DumpRenderTreeFinished(adb_cmd): """ Check if DumpRenderTree finished running tests - + Args: output: adb_cmd string """ - + # pull /sdcard/android/running_test.txt, if the content is "#DONE", it's done shell_cmd_str = adb_cmd + " shell cat /sdcard/android/running_test.txt" adb_output = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] @@ -69,7 +69,7 @@ def DiffResults(marker, new_results, old_results, diff_results, strip_reason, """ old_file = open(old_results, "r") new_file = open(new_results, "r") - diff_file = open(diff_results, "a") + diff_file = open(diff_results, "a") # Read lines from each file ndict = new_file.readlines() @@ -122,7 +122,7 @@ def CompareResults(ref_dir, results_dir): """ logging.info("Comparing results to " + ref_dir) - diff_result = os.path.join(results_dir, "layout_tests_diff.txt") + diff_result = os.path.join(results_dir, "layout_tests_diff.txt") if os.path.exists(diff_result): os.remove(diff_result) @@ -136,7 +136,7 @@ def CompareResults(ref_dir, results_dir): def main(options, args): """Run the tests. Will call sys.exit when complete. - + Args: options: a dictionary of command line options args: a list of sub directories or files to test @@ -198,7 +198,7 @@ def main(options, args): shell_cmd_str = adb_cmd + " shell cat /sdcard/android/running_test.txt" crashed_test = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE).communicate()[0] - + logging.info(crashed_test + " CRASHED"); crashed_tests.append(crashed_test); @@ -226,14 +226,15 @@ def main(options, args): result_files = ["/sdcard/layout_tests_passed.txt", "/sdcard/layout_tests_failed.txt", "/sdcard/layout_tests_nontext.txt"] - for file in result_files: + for file in result_files: shell_cmd_str = adb_cmd + " pull " + file + " " + results_dir adb_output = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] logging.debug(adb_output) - + # Create the crash list. fp = open(results_dir + "/layout_tests_crashed.txt", "w"); - fp.writelines('\n'.join(crashed_tests)) + for crashed_test in crashed_tests: + fp.writelines(crashed_test + '\n') fp.close() # Count the number of tests in each category. diff --git a/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java b/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java index df1876d..b069aad 100644 --- a/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java +++ b/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java @@ -24,35 +24,40 @@ import java.util.Map; * <p/> * <p/>{@link #getApiLevel()} gives the ability to know which methods are available. * <p/> + * Changes in API level 4: + * <ul> + * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, boolean, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> + * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> + * </ul> * Changes in API level 3: * <ul> - * <li>{@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> - * <li> deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> + * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> + * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * </ul> * Changes in API level 2: * <ul> - * <li>{@link #getApiLevel()}</li> - * <li>{@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> + * <li>new API Level method: {@link #getApiLevel()}</li> + * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, Map, Map, IProjectCallback, ILayoutLog)}</li> * </ul> */ public interface ILayoutBridge { - - final int API_CURRENT = 3; + + final int API_CURRENT = 4; /** * Returns the API level of the layout library. * While no methods will ever be removed, some may become deprecated, and some new ones * will appear. * <p/>If calling this method throws an {@link AbstractMethodError}, then the API level - * should be considered to be 1. + * should be considered to be 1. */ int getApiLevel(); /** * Initializes the Bridge object. * @param fontOsLocation the location of the fonts. - * @param enumValueMap map attrName => { map enumFlagName => Integer value }. + * @param enumValueMap map attrName => { map enumFlagName => Integer value }. * @return true if success. * @since 1 */ @@ -65,6 +70,44 @@ public interface ILayoutBridge { * @param projectKey An Object identifying the project. This is used for the cache mechanism. * @param screenWidth the screen width * @param screenHeight the screen height + * @param renderFullHeight if true, the rendering will render the full height needed by the + * layout. If the layout needs less than <var>screenHeight</var> then the rendering will + * use <var>screenHeight</var> as the height. + * @param density the density factor for the screen. + * @param xdpi the screen actual dpi in X + * @param ydpi the screen actual dpi in Y + * @param themeName The name of the theme to use. + * @param isProjectTheme true if the theme is a project theme, false if it is a framework theme. + * @param projectResources the resources of the project. The map contains (String, map) pairs + * where the string is the type of the resource reference used in the layout file, and the + * map contains (String, {@link IResourceValue}) pairs where the key is the resource name, + * and the value is the resource value. + * @param frameworkResources the framework resources. The map contains (String, map) pairs + * where the string is the type of the resource reference used in the layout file, and the map + * contains (String, {@link IResourceValue}) pairs where the key is the resource name, and the + * value is the resource value. + * @param projectCallback The {@link IProjectCallback} object to get information from + * the project. + * @param logger the object responsible for displaying warning/errors to the user. + * @return an {@link ILayoutResult} object that contains the result of the layout. + * @since 4 + */ + ILayoutResult computeLayout(IXmlPullParser layoutDescription, + Object projectKey, + int screenWidth, int screenHeight, boolean renderFullHeight, + int density, float xdpi, float ydpi, + String themeName, boolean isProjectTheme, + Map<String, Map<String, IResourceValue>> projectResources, + Map<String, Map<String, IResourceValue>> frameworkResources, + IProjectCallback projectCallback, ILayoutLog logger); + + /** + * Computes and renders a layout + * @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the + * layout file. + * @param projectKey An Object identifying the project. This is used for the cache mechanism. + * @param screenWidth the screen width + * @param screenHeight the screen height * @param density the density factor for the screen. * @param xdpi the screen actual dpi in X * @param ydpi the screen actual dpi in Y @@ -84,6 +127,7 @@ public interface ILayoutBridge { * @return an {@link ILayoutResult} object that contains the result of the layout. * @since 3 */ + @Deprecated ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey, int screenWidth, int screenHeight, int density, float xdpi, float ydpi, @@ -155,7 +199,7 @@ public interface ILayoutBridge { Map<String, Map<String, IResourceValue>> projectResources, Map<String, Map<String, IResourceValue>> frameworkResources, IProjectCallback projectCallback, ILayoutLog logger); - + /** * Clears the resource cache for a specific project. * <p/>This cache contains bitmaps and nine patches that are loaded from the disk and reused 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 6e26a05..02804e8 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java @@ -312,6 +312,7 @@ public final class Bridge implements ILayoutBridge { } /* + * For compatilibty purposes, we implement the old deprecated version of computeLayout. * (non-Javadoc) * @see com.android.layoutlib.api.ILayoutBridge#computeLayout(com.android.layoutlib.api.IXmlPullParser, java.lang.Object, int, int, int, float, float, java.lang.String, boolean, java.util.Map, java.util.Map, com.android.layoutlib.api.IProjectCallback, com.android.layoutlib.api.ILayoutLog) */ @@ -321,6 +322,23 @@ public final class Bridge implements ILayoutBridge { Map<String, Map<String, IResourceValue>> projectResources, Map<String, Map<String, IResourceValue>> frameworkResources, IProjectCallback customViewLoader, ILayoutLog logger) { + return computeLayout(layoutDescription, projectKey, + screenWidth, screenHeight, false /* renderFullHeight */, + density, xdpi, ydpi, themeName, isProjectTheme, + projectResources, frameworkResources, customViewLoader, logger); + } + + /* + * (non-Javadoc) + * @see com.android.layoutlib.api.ILayoutBridge#computeLayout(com.android.layoutlib.api.IXmlPullParser, java.lang.Object, int, int, boolean, int, float, float, java.lang.String, boolean, java.util.Map, java.util.Map, com.android.layoutlib.api.IProjectCallback, com.android.layoutlib.api.ILayoutLog) + */ + public ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey, + int screenWidth, int screenHeight, boolean renderFullHeight, + int density, float xdpi, float ydpi, + String themeName, boolean isProjectTheme, + Map<String, Map<String, IResourceValue>> projectResources, + Map<String, Map<String, IResourceValue>> frameworkResources, + IProjectCallback customViewLoader, ILayoutLog logger) { if (logger == null) { logger = sDefaultLogger; } @@ -393,15 +411,33 @@ public final class Bridge implements ILayoutBridge { root.setBackgroundDrawable(d); } + // measure the views int w_spec = MeasureSpec.makeMeasureSpec(screenWidth, MeasureSpec.EXACTLY); - int h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset, - MeasureSpec.EXACTLY); + int h_spec; - // measure the views + if (renderFullHeight) { + // measure the full height needed by the layout. + h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset, + MeasureSpec.UNSPECIFIED); // this lets us know the actual needed size + view.measure(w_spec, h_spec); + + int neededHeight = root.getChildAt(0).getMeasuredHeight(); + + if (neededHeight > screenHeight - screenOffset) { + screenHeight = neededHeight + screenOffset; + } + } + + // remeasure with only the size we need + // This must always be done before the call to layout + h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset, + MeasureSpec.EXACTLY); view.measure(w_spec, h_spec); + + // now do the layout. view.layout(0, screenOffset, screenWidth, screenHeight); - // draw them + // draw the views Canvas canvas = new Canvas(screenWidth, screenHeight - screenOffset, logger); root.draw(canvas); @@ -1017,7 +1053,7 @@ public final class Bridge implements ILayoutBridge { public void setWallpaperPosition(IBinder window, float x, float y) { // pass for now. } - + public IBinder asBinder() { // pass for now. return null; |
