diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/animation/LayoutTransition.java | 9 | ||||
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 23 | ||||
| -rw-r--r-- | core/java/android/provider/Settings.java | 10 | ||||
| -rwxr-xr-x | core/java/android/provider/Telephony.java | 10 | ||||
| -rw-r--r-- | core/java/android/view/GLES20Canvas.java | 21 | ||||
| -rw-r--r-- | core/java/android/view/HardwareRenderer.java | 90 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 16 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 4 | ||||
| -rw-r--r-- | core/java/android/view/WindowManagerImpl.java | 27 | ||||
| -rw-r--r-- | core/java/android/widget/ImageView.java | 24 |
10 files changed, 196 insertions, 38 deletions
diff --git a/core/java/android/animation/LayoutTransition.java b/core/java/android/animation/LayoutTransition.java index f383af9..7f0ea99 100644 --- a/core/java/android/animation/LayoutTransition.java +++ b/core/java/android/animation/LayoutTransition.java @@ -657,6 +657,15 @@ public class LayoutTransition { */ private void setupChangeAnimation(final ViewGroup parent, final int changeReason, Animator baseAnimator, final long duration, final View child) { + + // If we already have a listener for this child, then we've already set up the + // changing animation we need. Multiple calls for a child may occur when several + // add/remove operations are run at once on a container; each one will trigger + // changes for the existing children in the container. + if (layoutChangeListenerMap.get(child) != null) { + return; + } + // Make a copy of the appropriate animation final Animator anim = baseAnimator.clone(); diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index a4714ca..f9896f7 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -45,6 +45,7 @@ import android.graphics.Canvas; import android.net.IConnectivityManager; import android.net.Proxy; import android.net.ProxyProperties; +import android.opengl.GLUtils; import android.os.AsyncTask; import android.os.Bundle; import android.os.Debug; @@ -3714,6 +3715,24 @@ public final class ActivityThread { } } + private void setupGraphicsSupport(LoadedApk info) { + try { + int uid = Process.myUid(); + String[] packages = getPackageManager().getPackagesForUid(uid); + + // If there are several packages in this application we won't + // initialize the graphics disk caches + if (packages.length == 1) { + ContextImpl appContext = new ContextImpl(); + appContext.init(info, null, this); + + HardwareRenderer.setupDiskCache(appContext.getCacheDir()); + } + } catch (RemoteException e) { + // Ignore + } + } + private void handleBindApplication(AppBindData data) { mBoundApplication = data; mConfiguration = new Configuration(data.config); @@ -3737,7 +3756,7 @@ public final class ActivityThread { HardwareRenderer.disable(false); } } - + if (mProfiler.profileFd != null) { mProfiler.startProfiling(); } @@ -3773,6 +3792,8 @@ public final class ActivityThread { data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo); + setupGraphicsSupport(data.info); + /** * For system applications on userdebug/eng builds, log stack * traces of disk and network access to dropbox for analysis. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 769776e..b032169 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -4077,13 +4077,6 @@ public final class Settings { "contacts_preauth_uri_expiration"; /** - * Whether the Messaging app posts notifications. - * 0=disabled. 1=enabled. - */ - public static final String MESSAGING_APP_NOTIFICATIONS = "messaging_app_notifications"; - - - /** * This are the settings to be backed up. * * NOTE: Settings are backed up and restored in the order they appear @@ -4120,8 +4113,7 @@ public final class Settings { MOUNT_UMS_NOTIFY_ENABLED, UI_NIGHT_MODE, LOCK_SCREEN_OWNER_INFO, - LOCK_SCREEN_OWNER_INFO_ENABLED, - MESSAGING_APP_NOTIFICATIONS + LOCK_SCREEN_OWNER_INFO_ENABLED }; /** diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 8eb9da1..0e6d07d 100755 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -1838,15 +1838,5 @@ public final class Telephony { public static final String EXTRA_PLMN = "plmn"; public static final String EXTRA_SHOW_SPN = "showSpn"; public static final String EXTRA_SPN = "spn"; - - /** - * Activity Action: Shows a dialog to turn off Messaging app notification. - * <p>Input: Nothing. - * <p>Output: Nothing. - */ - @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) - public static final String ACTION_MESSAGING_APP_NOTIFICATIONS = - "android.provider.Telephony.MESSAGING_APP_NOTIFICATIONS"; - } } diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java index c934c7b..d948ec2 100644 --- a/core/java/android/view/GLES20Canvas.java +++ b/core/java/android/view/GLES20Canvas.java @@ -315,6 +315,27 @@ class GLES20Canvas extends HardwareCanvas { private static native void nFlushCaches(int level); + /** + * Release all resources associated with the underlying caches. This should + * only be called after a full flushCaches(). + * + * @hide + */ + public static void terminateCaches() { + nTerminateCaches(); + } + + private static native void nTerminateCaches(); + + /** + * @hide + */ + public static void initCaches() { + nInitCaches(); + } + + private static native void nInitCaches(); + /////////////////////////////////////////////////////////////////////////// // Display list /////////////////////////////////////////////////////////////////////////// diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index b86d21d..e0167d8 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -25,6 +25,7 @@ import android.opengl.GLUtils; import android.os.SystemClock; import android.os.SystemProperties; import android.util.Log; +import com.google.android.gles_jni.EGLImpl; import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL11; @@ -34,6 +35,8 @@ import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.egl.EGLSurface; import javax.microedition.khronos.opengles.GL; +import java.io.File; + import static javax.microedition.khronos.egl.EGL10.*; /** @@ -45,6 +48,11 @@ public abstract class HardwareRenderer { static final String LOG_TAG = "HardwareRenderer"; /** + * Name of the file that holds the shaders cache. + */ + private static final String CACHE_PATH_SHADERS = "com.android.opengl.shaders_cache"; + + /** * Turn on to only refresh the parts of the screen that need updating. * When turned on the property defined by {@link #RENDER_DIRTY_REGIONS_PROPERTY} * must also have the value "true". @@ -200,6 +208,18 @@ public abstract class HardwareRenderer { abstract int getHeight(); /** + * Sets the directory to use as a persistent storage for hardware rendering + * resources. + * + * @param cacheDir A directory the current process can write to + */ + public static void setupDiskCache(File cacheDir) { + nSetupShadersDiskCache(new File(cacheDir, CACHE_PATH_SHADERS).getAbsolutePath()); + } + + private static native void nSetupShadersDiskCache(String cacheFile); + + /** * Interface used to receive callbacks whenever a view is drawn by * a hardware renderer instance. */ @@ -325,6 +345,15 @@ public abstract class HardwareRenderer { } /** + * Invoke this method when the system needs to clean up all resources + * associated with hardware rendering. + */ + static void terminate() { + Log.d(LOG_TAG, "Terminating hardware rendering"); + Gl20Renderer.terminate(); + } + + /** * Indicates whether hardware acceleration is currently enabled. * * @return True if hardware acceleration is in use, false otherwise. @@ -632,6 +661,8 @@ public abstract class HardwareRenderer { throw new Surface.OutOfResourcesException("eglMakeCurrent failed " + GLUtils.getEGLErrorString(sEgl.eglGetError())); } + + initCaches(); // If mDirtyRegions is set, this means we have an EGL configuration // with EGL_SWAP_BEHAVIOR_PRESERVED_BIT set @@ -652,6 +683,8 @@ public abstract class HardwareRenderer { return mEglContext.getGL(); } + abstract void initCaches(); + EGLContext createContext(EGL10 egl, EGLDisplay eglDisplay, EGLConfig eglConfig) { int[] attribs = { EGL_CONTEXT_CLIENT_VERSION, mGlVersion, EGL_NONE }; @@ -895,6 +928,11 @@ public abstract class HardwareRenderer { EGL_NONE }; } + + @Override + void initCaches() { + GLES20Canvas.initCaches(); + } @Override boolean canDraw() { @@ -987,16 +1025,7 @@ public abstract class HardwareRenderer { if (eglContext == null) { return; } else { - synchronized (sPbufferLock) { - // Create a temporary 1x1 pbuffer so we have a context - // to clear our OpenGL objects - if (sPbuffer == null) { - sPbuffer = sEgl.eglCreatePbufferSurface(sEglDisplay, sEglConfig, new int[] { - EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE - }); - } - } - sEgl.eglMakeCurrent(sEglDisplay, sPbuffer, sPbuffer, eglContext); + usePbufferSurface(eglContext); } switch (level) { @@ -1010,5 +1039,46 @@ public abstract class HardwareRenderer { break; } } + + private static void usePbufferSurface(EGLContext eglContext) { + synchronized (sPbufferLock) { + // Create a temporary 1x1 pbuffer so we have a context + // to clear our OpenGL objects + if (sPbuffer == null) { + sPbuffer = sEgl.eglCreatePbufferSurface(sEglDisplay, sEglConfig, new int[] { + EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE + }); + } + } + sEgl.eglMakeCurrent(sEglDisplay, sPbuffer, sPbuffer, eglContext); + } + + static void terminate() { + synchronized (sEglLock) { + if (sEgl == null) return; + + if (EGLImpl.getInitCount(sEglDisplay) == 1) { + EGLContext eglContext = sEglContextStorage.get(); + if (eglContext == null) return; + + usePbufferSurface(eglContext); + GLES20Canvas.terminateCaches(); + + sEgl.eglDestroyContext(sEglDisplay, eglContext); + sEglContextStorage.remove(); + + sEgl.eglDestroySurface(sEglDisplay, sPbuffer); + sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + sEgl.eglReleaseThread(); + sEgl.eglTerminate(sEglDisplay); + + sEgl = null; + sEglDisplay = null; + sEglConfig = null; + sPbuffer = null; + } + } + } } } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 62e6ebd..dc46d42 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -11402,8 +11402,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * {@link SystemClock#uptimeMillis} timebase. */ public void scheduleDrawable(Drawable who, Runnable what, long when) { - if (verifyDrawable(who) && what != null && mAttachInfo != null) { - mAttachInfo.mHandler.postAtTime(what, who, when); + if (verifyDrawable(who) && what != null) { + if (mAttachInfo != null) { + mAttachInfo.mHandler.postAtTime(what, who, when); + } else { + ViewRootImpl.getRunQueue().postDelayed(what, when - SystemClock.uptimeMillis()); + } } } @@ -11414,8 +11418,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * @param what the action to cancel */ public void unscheduleDrawable(Drawable who, Runnable what) { - if (verifyDrawable(who) && what != null && mAttachInfo != null) { - mAttachInfo.mHandler.removeCallbacks(what, who); + if (verifyDrawable(who) && what != null) { + if (mAttachInfo != null) { + mAttachInfo.mHandler.removeCallbacks(what, who); + } else { + ViewRootImpl.getRunQueue().removeCallbacks(what); + } } } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index f7078ec..b15b155 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -567,7 +567,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, } } - private void destroyHardwareResources() { + void destroyHardwareResources() { if (mAttachInfo.mHardwareRenderer != null) { if (mAttachInfo.mHardwareRenderer.isEnabled()) { mAttachInfo.mHardwareRenderer.destroyLayers(mView); @@ -880,12 +880,10 @@ public final class ViewRootImpl extends Handler implements ViewParent, || mNewSurfaceNeeded; WindowManager.LayoutParams params = null; - int windowAttributesChanges = 0; if (mWindowAttributesChanged) { mWindowAttributesChanged = false; surfaceChanged = true; params = lp; - windowAttributesChanges = mWindowAttributesChangesFlag; } CompatibilityInfo compatibilityInfo = mCompatibilityInfo.get(); if (compatibilityInfo.supportsScreen() == mLastInCompatMode) { diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index 5ef4f3e..d89bc36 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -16,6 +16,8 @@ package android.view; +import android.app.ActivityManager; +import android.content.ComponentCallbacks2; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.PixelFormat; @@ -409,7 +411,30 @@ public class WindowManagerImpl implements WindowManager { */ public void trimMemory(int level) { if (HardwareRenderer.isAvailable()) { - HardwareRenderer.trimMemory(level); + switch (level) { + case ComponentCallbacks2.TRIM_MEMORY_COMPLETE: + case ComponentCallbacks2.TRIM_MEMORY_MODERATE: + // On low and medium end gfx devices + if (!ActivityManager.isHighEndGfx(getDefaultDisplay())) { + // Force a full memory flush + HardwareRenderer.trimMemory(ComponentCallbacks2.TRIM_MEMORY_COMPLETE); + // Destroy all hardware surfaces and resources associated to + // known windows + synchronized (this) { + if (mViews == null) return; + int count = mViews.length; + for (int i = 0; i < count; i++) { + mRoots[i].destroyHardwareResources(); + } + } + // Terminate the hardware renderer to free all resources + HardwareRenderer.terminate(); + break; + } + // high end gfx devices fall through to next case + default: + HardwareRenderer.trimMemory(level); + } } } diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index b24dd69..c1e36ed 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -1035,4 +1035,28 @@ public class ImageView extends View { mDrawable.setAlpha(mAlpha * mViewAlphaScale >> 8); } } + + @Override + public void setVisibility(int visibility) { + super.setVisibility(visibility); + if (mDrawable != null) { + mDrawable.setVisible(visibility == VISIBLE, false); + } + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (mDrawable != null) { + mDrawable.setVisible(getVisibility() == VISIBLE, false); + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + if (mDrawable != null) { + mDrawable.setVisible(false, false); + } + } } |
