diff options
-rw-r--r-- | api/current.xml | 11 | ||||
-rw-r--r-- | core/java/android/animation/LayoutTransition.java | 108 | ||||
-rw-r--r-- | core/java/android/view/View.java | 31 | ||||
-rw-r--r-- | core/java/android/view/ViewGroup.java | 6 | ||||
-rw-r--r-- | data/sounds/effects/ogg/Lock.ogg | bin | 20013 -> 20257 bytes | |||
-rw-r--r-- | services/java/com/android/server/usb/UsbService.java | 50 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 6 |
7 files changed, 154 insertions, 58 deletions
diff --git a/api/current.xml b/api/current.xml index 9993475..c1d2f66 100644 --- a/api/current.xml +++ b/api/current.xml @@ -220707,6 +220707,17 @@ <parameter name="autoScale" type="boolean"> </parameter> </method> +<method name="buildLayer" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="cancelLongPress" return="void" abstract="false" diff --git a/core/java/android/animation/LayoutTransition.java b/core/java/android/animation/LayoutTransition.java index 8b59554..22dd3c7 100644 --- a/core/java/android/animation/LayoutTransition.java +++ b/core/java/android/animation/LayoutTransition.java @@ -168,7 +168,9 @@ public class LayoutTransition { */ private final HashMap<View, Animator> pendingAnimations = new HashMap<View, Animator>(); private final HashMap<View, Animator> currentChangingAnimations = new HashMap<View, Animator>(); - private final HashMap<View, Animator> currentVisibilityAnimations = + private final HashMap<View, Animator> currentAppearingAnimations = + new HashMap<View, Animator>(); + private final HashMap<View, Animator> currentDisappearingAnimations = new HashMap<View, Animator>(); /** @@ -709,7 +711,8 @@ public class LayoutTransition { * @return true if any animations in the transition are running. */ public boolean isRunning() { - return (currentChangingAnimations.size() > 0 || currentVisibilityAnimations.size() > 0); + return (currentChangingAnimations.size() > 0 || currentAppearingAnimations.size() > 0 || + currentDisappearingAnimations.size() > 0); } /** @@ -721,17 +724,74 @@ public class LayoutTransition { * @hide */ public void cancel() { - HashMap<View, Animator> currentAnimCopy = - (HashMap<View, Animator>) currentChangingAnimations.clone(); - for (Animator anim : currentAnimCopy.values()) { - anim.cancel(); + if (currentChangingAnimations.size() > 0) { + HashMap<View, Animator> currentAnimCopy = + (HashMap<View, Animator>) currentChangingAnimations.clone(); + for (Animator anim : currentAnimCopy.values()) { + anim.cancel(); + } + currentChangingAnimations.clear(); + } + if (currentAppearingAnimations.size() > 0) { + HashMap<View, Animator> currentAnimCopy = + (HashMap<View, Animator>) currentAppearingAnimations.clone(); + for (Animator anim : currentAnimCopy.values()) { + anim.end(); + } + currentAppearingAnimations.clear(); } - currentChangingAnimations.clear(); - currentAnimCopy = (HashMap<View, Animator>) currentVisibilityAnimations.clone(); - for (Animator anim : currentAnimCopy.values()) { - anim.end(); + if (currentDisappearingAnimations.size() > 0) { + HashMap<View, Animator> currentAnimCopy = + (HashMap<View, Animator>) currentDisappearingAnimations.clone(); + for (Animator anim : currentAnimCopy.values()) { + anim.end(); + } + currentDisappearingAnimations.clear(); + } + } + + /** + * Cancels the specified type of transition. Note that we cancel() the changing animations + * but end() the visibility animations. This is because this method is currently called + * in the context of starting a new transition, so we want to move things from their mid- + * transition positions, but we want them to have their end-transition visibility. + * + * @hide + */ + public void cancel(int transitionType) { + switch (transitionType) { + case CHANGE_APPEARING: + case CHANGE_DISAPPEARING: + if (currentChangingAnimations.size() > 0) { + HashMap<View, Animator> currentAnimCopy = + (HashMap<View, Animator>) currentChangingAnimations.clone(); + for (Animator anim : currentAnimCopy.values()) { + anim.cancel(); + } + currentChangingAnimations.clear(); + } + break; + case APPEARING: + if (currentAppearingAnimations.size() > 0) { + HashMap<View, Animator> currentAnimCopy = + (HashMap<View, Animator>) currentAppearingAnimations.clone(); + for (Animator anim : currentAnimCopy.values()) { + anim.end(); + } + currentAppearingAnimations.clear(); + } + break; + case DISAPPEARING: + if (currentDisappearingAnimations.size() > 0) { + HashMap<View, Animator> currentAnimCopy = + (HashMap<View, Animator>) currentDisappearingAnimations.clone(); + for (Animator anim : currentAnimCopy.values()) { + anim.end(); + } + currentDisappearingAnimations.clear(); + } + break; } - currentVisibilityAnimations.clear(); } /** @@ -741,7 +801,7 @@ public class LayoutTransition { * @param child The View being added to the ViewGroup. */ private void runAppearingTransition(final ViewGroup parent, final View child) { - Animator currentAnimation = currentVisibilityAnimations.get(child); + Animator currentAnimation = currentDisappearingAnimations.get(child); if (currentAnimation != null) { currentAnimation.cancel(); } @@ -764,14 +824,14 @@ public class LayoutTransition { anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator anim) { - currentVisibilityAnimations.remove(child); + currentAppearingAnimations.remove(child); for (TransitionListener listener : mListeners) { listener.endTransition(LayoutTransition.this, parent, child, APPEARING); } } }); } - currentVisibilityAnimations.put(child, anim); + currentAppearingAnimations.put(child, anim); anim.start(); } @@ -782,7 +842,7 @@ public class LayoutTransition { * @param child The View being removed from the ViewGroup. */ private void runDisappearingTransition(final ViewGroup parent, final View child) { - Animator currentAnimation = currentVisibilityAnimations.get(child); + Animator currentAnimation = currentAppearingAnimations.get(child); if (currentAnimation != null) { currentAnimation.cancel(); } @@ -802,7 +862,7 @@ public class LayoutTransition { anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator anim) { - currentVisibilityAnimations.remove(child); + currentDisappearingAnimations.remove(child); for (TransitionListener listener : mListeners) { listener.endTransition(LayoutTransition.this, parent, child, DISAPPEARING); } @@ -812,7 +872,7 @@ public class LayoutTransition { if (anim instanceof ObjectAnimator) { ((ObjectAnimator) anim).setCurrentPlayTime(0); } - currentVisibilityAnimations.put(child, anim); + currentDisappearingAnimations.put(child, anim); anim.start(); } @@ -826,9 +886,10 @@ public class LayoutTransition { * @param child The View being added to the ViewGroup. */ public void addChild(ViewGroup parent, View child) { - if (isRunning()) { - cancel(); - } + // Want disappearing animations to finish up before proceeding + cancel(DISAPPEARING); + // Also, cancel changing animations so that we start fresh ones from current locations + cancel(CHANGE_APPEARING); if (mListeners != null) { for (TransitionListener listener : mListeners) { listener.startTransition(this, parent, child, APPEARING); @@ -861,9 +922,10 @@ public class LayoutTransition { * @param child The View being removed from the ViewGroup. */ public void removeChild(ViewGroup parent, View child) { - if (isRunning()) { - cancel(); - } + // Want appearing animations to finish up before proceeding + cancel(APPEARING); + // Also, cancel changing animations so that we start fresh ones from current locations + cancel(CHANGE_DISAPPEARING); if (mListeners != null) { for (TransitionListener listener : mListeners) { listener.startTransition(this, parent, child, DISAPPEARING); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 2170d72..32c9e27 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8488,6 +8488,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * {@link #LAYER_TYPE_HARDWARE} * * @see #setLayerType(int, android.graphics.Paint) + * @see #buildLayer() * @see #LAYER_TYPE_NONE * @see #LAYER_TYPE_SOFTWARE * @see #LAYER_TYPE_HARDWARE @@ -8497,6 +8498,36 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } /** + * Forces this view's layer to be created and this view to be rendered + * into its layer. If this view's layer type is set to {@link #LAYER_TYPE_NONE}, + * invoking this method will have no effect. + * + * This method can for instance be used to render a view into its layer before + * starting an animation. If this view is complex, rendering into the layer + * before starting the animation will avoid skipping frames. + * + * @throws IllegalStateException If this view is not attached to a window + * + * @see #setLayerType(int, android.graphics.Paint) + */ + public void buildLayer() { + if (mLayerType == LAYER_TYPE_NONE) return; + + if (mAttachInfo == null) { + throw new IllegalStateException("This view must be attached to a window first"); + } + + switch (mLayerType) { + case LAYER_TYPE_HARDWARE: + getHardwareLayer(); + break; + case LAYER_TYPE_SOFTWARE: + buildDrawingCache(true); + break; + } + } + + /** * <p>Returns a hardware layer that can be used to draw this view again * without executing its draw method.</p> * diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index af4c221..3153ac5 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -3001,8 +3001,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager private void addViewInner(View child, int index, LayoutParams params, boolean preventRequestLayout) { - if (mTransition != null && mTransition.isRunning()) { - mTransition.cancel(); + if (mTransition != null) { + // Don't prevent other add transitions from completing, but cancel remove + // transitions to let them complete the process before we add to the container + mTransition.cancel(LayoutTransition.DISAPPEARING); } if (child.getParent() != null) { diff --git a/data/sounds/effects/ogg/Lock.ogg b/data/sounds/effects/ogg/Lock.ogg Binary files differindex 2e57d9e..a25513f 100644 --- a/data/sounds/effects/ogg/Lock.ogg +++ b/data/sounds/effects/ogg/Lock.ogg diff --git a/services/java/com/android/server/usb/UsbService.java b/services/java/com/android/server/usb/UsbService.java index 94c25e9..8170c61 100644 --- a/services/java/com/android/server/usb/UsbService.java +++ b/services/java/com/android/server/usb/UsbService.java @@ -102,8 +102,8 @@ public class UsbService extends IUsbManager.Stub { private boolean mSystemReady; private UsbAccessory mCurrentAccessory; - // functions to restore after exiting accessory mode - private final ArrayList<String> mAccessoryRestoreFunctions = new ArrayList<String>(); + // USB functions that are enabled by default, to restore after exiting accessory mode + private final ArrayList<String> mDefaultFunctions = new ArrayList<String>(); private final Context mContext; private final Object mLock = new Object(); @@ -118,20 +118,6 @@ public class UsbService extends IUsbManager.Stub { boolean enteringAccessoryMode = (mHasUsbAccessory && enabled && UsbManager.USB_FUNCTION_ACCESSORY.equals(function)); - if (enteringAccessoryMode) { - // keep a list of functions to reenable after exiting accessory mode - mAccessoryRestoreFunctions.clear(); - int count = mEnabledFunctions.size(); - for (int i = 0; i < count; i++) { - String f = mEnabledFunctions.get(i); - // RNDIS should not be restored and adb is handled automatically - if (!UsbManager.USB_FUNCTION_RNDIS.equals(f) && - !UsbManager.USB_FUNCTION_ADB.equals(f) && - !UsbManager.USB_FUNCTION_ACCESSORY.equals(f)) { - mAccessoryRestoreFunctions.add(f); - } - } - } if (enabled) { if (!mEnabledFunctions.contains(function)) { mEnabledFunctions.add(function); @@ -261,6 +247,11 @@ public class UsbService extends IUsbManager.Stub { String functionName = files[i].getName(); if (value == 1) { mEnabledFunctions.add(functionName); + // adb is enabled/disabled automatically by the adbd daemon, + // so don't treat it as a default function + if (!UsbManager.USB_FUNCTION_ADB.equals(functionName)) { + mDefaultFunctions.add(functionName); + } } else { mDisabledFunctions.add(functionName); } @@ -503,29 +494,24 @@ public class UsbService extends IUsbManager.Stub { switch (msg.what) { case MSG_UPDATE_STATE: if (mConnected != mLastConnected || mConfiguration != mLastConfiguration) { - if (mConnected == 0 && mCurrentAccessory != null) { - // turn off accessory mode when we are disconnected + if (mConnected == 0) { + // make sure accessory mode is off, and restore default functions if (UsbManager.setFunctionEnabled( UsbManager.USB_FUNCTION_ACCESSORY, false)) { Log.d(TAG, "exited USB accessory mode"); - // restore previously enabled functions - for (String function : mAccessoryRestoreFunctions) { + int count = mDefaultFunctions.size(); + for (int i = 0; i < count; i++) { + String function = mDefaultFunctions.get(i); if (UsbManager.setFunctionEnabled(function, true)) { Log.e(TAG, "could not reenable function " + function); } } - mAccessoryRestoreFunctions.clear(); + } + if (mCurrentAccessory != null) { mDeviceManager.accessoryDetached(mCurrentAccessory); mCurrentAccessory = null; - - // this will cause an immediate reset of the USB bus, - // so there is no point in sending the - // function disabled broadcast. - return; - } else { - Log.e(TAG, "could not disable USB_FUNCTION_ACCESSORY"); } } @@ -581,14 +567,18 @@ public class UsbService extends IUsbManager.Stub { pw.print(mDisabledFunctions.get(i) + " "); } pw.println(""); + pw.print(" Default Functions: "); + for (int i = 0; i < mDefaultFunctions.size(); i++) { + pw.print(mDefaultFunctions.get(i) + " "); + } + pw.println(""); pw.println(" mConnected: " + mConnected + ", mConfiguration: " + mConfiguration); + pw.println(" mCurrentAccessory: " + mCurrentAccessory); pw.println(" USB Host State:"); for (String name : mDevices.keySet()) { pw.println(" " + name + ": " + mDevices.get(name)); } - pw.println(" mCurrentAccessory: " + mCurrentAccessory); - mDeviceManager.dump(fd, pw); } } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 40882d8..554fa43 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2150,8 +2150,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, sh = (!sh) ? hw_h : sh; const size_t size = sw * sh * 4; - LOGD("screenshot: sw=%d, sh=%d, minZ=%d, maxZ=%d", - sw, sh, minLayerZ, maxLayerZ); + //LOGD("screenshot: sw=%d, sh=%d, minZ=%d, maxZ=%d", + // sw, sh, minLayerZ, maxLayerZ); // make sure to clear all GL error flags while ( glGetError() != GL_NO_ERROR ) ; @@ -2236,7 +2236,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, hw.compositionComplete(); - LOGD("screenshot: result = %s", result<0 ? strerror(result) : "OK"); + // LOGD("screenshot: result = %s", result<0 ? strerror(result) : "OK"); return result; } |