diff options
25 files changed, 428 insertions, 127 deletions
diff --git a/api/current.txt b/api/current.txt index 0603a63..77c9f6e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -27518,14 +27518,24 @@ package android.widget { ctor public Switch(android.content.Context); ctor public Switch(android.content.Context, android.util.AttributeSet); ctor public Switch(android.content.Context, android.util.AttributeSet, int); + method public int getSwitchMinWidth(); + method public int getSwitchPadding(); method public java.lang.CharSequence getTextOff(); method public java.lang.CharSequence getTextOn(); + method public android.graphics.drawable.Drawable getThumbDrawable(); + method public int getThumbTextPadding(); + method public android.graphics.drawable.Drawable getTrackDrawable(); method public void onMeasure(int, int); + method public void setSwitchMinWidth(int); + method public void setSwitchPadding(int); method public void setSwitchTextAppearance(android.content.Context, int); method public void setSwitchTypeface(android.graphics.Typeface, int); method public void setSwitchTypeface(android.graphics.Typeface); method public void setTextOff(java.lang.CharSequence); method public void setTextOn(java.lang.CharSequence); + method public void setThumbDrawable(android.graphics.drawable.Drawable); + method public void setThumbTextPadding(int); + method public void setTrackDrawable(android.graphics.drawable.Drawable); } public class TabHost extends android.widget.FrameLayout implements android.view.ViewTreeObserver.OnTouchModeChangeListener { diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java index 6fbeee3..954ae66 100755 --- a/core/java/android/animation/ValueAnimator.java +++ b/core/java/android/animation/ValueAnimator.java @@ -645,7 +645,7 @@ public class ValueAnimator extends Animator { // onAnimate to process the next frame of the animations. if (!mAnimationScheduled && (!mAnimations.isEmpty() || !mDelayedAnims.isEmpty())) { - mChoreographer.postAnimationCallback(this); + mChoreographer.postAnimationCallback(this, null); mAnimationScheduled = true; } } diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index 215e836..6c1445d 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -28,6 +28,8 @@ import java.util.regex.Pattern; import java.util.zip.CRC32; import java.util.zip.CheckedInputStream; +import libcore.io.Os; +import libcore.io.StructStat; /** * Tools for managing files. Not for public consumption. @@ -52,8 +54,10 @@ public class FileUtils { /** * File status information. This class maps directly to the POSIX stat structure. + * @deprecated use {@link StructStat} instead. * @hide */ + @Deprecated public static final class FileStatus { public int dev; public int ino; @@ -77,7 +81,9 @@ public class FileUtils { * exists. * @return true if the file exists and false if it does not exist. If you do not have * permission to stat the file, then this method will return false. + * @deprecated use {@link Os#stat(String)} instead. */ + @Deprecated public static boolean getFileStatus(String path, FileStatus status) { StrictMode.noteDiskRead(); return getFileStatusNative(path, status); @@ -90,6 +96,10 @@ public class FileUtils { public static native int setPermissions(String file, int mode, int uid, int gid); + /** + * @deprecated use {@link Os#stat(String)} instead. + */ + @Deprecated public static native int getPermissions(String file, int[] outPermissions); public static native int setUMask(int mask); diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java index f4d7af9..10edc06 100644 --- a/core/java/android/view/Choreographer.java +++ b/core/java/android/view/Choreographer.java @@ -81,8 +81,8 @@ public final class Choreographer { private static final int MSG_DO_ANIMATION = 0; private static final int MSG_DO_DRAW = 1; private static final int MSG_DO_SCHEDULE_VSYNC = 2; - private static final int MSG_POST_DELAYED_ANIMATION = 3; - private static final int MSG_POST_DELAYED_DRAW = 4; + private static final int MSG_DO_SCHEDULE_ANIMATION = 3; + private static final int MSG_DO_SCHEDULE_DRAW = 4; private final Object mLock = new Object(); @@ -152,134 +152,158 @@ public final class Choreographer { } /** + * Subtracts typical frame delay time from a delay interval in milliseconds. + * + * This method can be used to compensate for animation delay times that have baked + * in assumptions about the frame delay. For example, it's quite common for code to + * assume a 60Hz frame time and bake in a 16ms delay. When we call + * {@link #postAnimationCallbackDelayed} we want to know how long to wait before + * posting the animation callback but let the animation timer take care of the remaining + * frame delay time. + * + * This method is somewhat conservative about how much of the frame delay it + * subtracts. It uses the same value returned by {@link #getFrameDelay} which by + * default is 10ms even though many parts of the system assume 16ms. Consequently, + * we might still wait 6ms before posting an animation callback that we want to run + * on the next frame, but this is much better than waiting a whole 16ms and likely + * missing the deadline. + * + * @param delayMillis The original delay time including an assumed frame delay. + * @return The adjusted delay time with the assumed frame delay subtracted out. + */ + public static long subtractFrameDelay(long delayMillis) { + final long frameDelay = sFrameDelay; + return delayMillis <= frameDelay ? 0 : delayMillis - frameDelay; + } + + /** * Posts a callback to run on the next animation cycle. * The callback only runs once and then is automatically removed. * - * @param runnable The callback to run during the next animation cycle. + * @param action The callback action to run during the next animation cycle. + * @param token The callback token, or null if none. * * @see #removeAnimationCallback */ - public void postAnimationCallback(Runnable runnable) { - if (runnable == null) { - throw new IllegalArgumentException("runnable must not be null"); - } - postAnimationCallbackUnchecked(runnable); - } - - private void postAnimationCallbackUnchecked(Runnable runnable) { - synchronized (mLock) { - mAnimationCallbacks = addCallbackLocked(mAnimationCallbacks, runnable); - scheduleAnimationLocked(); - } + public void postAnimationCallback(Runnable action, Object token) { + postAnimationCallbackDelayed(action, token, 0); } /** * Posts a callback to run on the next animation cycle following the specified delay. * The callback only runs once and then is automatically removed. * - * @param runnable The callback to run during the next animation cycle following + * @param action The callback action to run during the next animation cycle after * the specified delay. + * @param token The callback token, or null if none. * @param delayMillis The delay time in milliseconds. * * @see #removeAnimationCallback */ - public void postAnimationCallbackDelayed(Runnable runnable, long delayMillis) { - if (runnable == null) { - throw new IllegalArgumentException("runnable must not be null"); + public void postAnimationCallbackDelayed(Runnable action, Object token, long delayMillis) { + if (action == null) { + throw new IllegalArgumentException("action must not be null"); } - if (delayMillis <= 0) { - postAnimationCallbackUnchecked(runnable); - } else { - Message msg = mHandler.obtainMessage(MSG_POST_DELAYED_ANIMATION, runnable); - mHandler.sendMessageDelayed(msg, delayMillis); + + synchronized (mLock) { + final long now = SystemClock.uptimeMillis(); + final long dueTime = now + delayMillis; + mAnimationCallbacks = addCallbackLocked(mAnimationCallbacks, dueTime, action, token); + + if (dueTime <= now) { + scheduleAnimationLocked(now); + } else { + Message msg = mHandler.obtainMessage(MSG_DO_SCHEDULE_ANIMATION, action); + mHandler.sendMessageAtTime(msg, dueTime); + } } } /** - * Removes animation callbacks for the specified runnable. - * Does nothing if the specified animation callback has not been posted or has already - * been removed. + * Removes animation callbacks that have the specified action and token. * - * @param runnable The animation callback to remove. + * @param action The action property of the callbacks to remove, or null to remove + * callbacks with any action. + * @param token The token property of the callbacks to remove, or null to remove + * callbacks with any token. * * @see #postAnimationCallback * @see #postAnimationCallbackDelayed */ - public void removeAnimationCallbacks(Runnable runnable) { - if (runnable == null) { - throw new IllegalArgumentException("runnable must not be null"); - } + public void removeAnimationCallbacks(Runnable action, Object token) { synchronized (mLock) { - mAnimationCallbacks = removeCallbacksLocked(mAnimationCallbacks, runnable); + mAnimationCallbacks = removeCallbacksLocked(mAnimationCallbacks, action, token); + if (action != null && token == null) { + mHandler.removeMessages(MSG_DO_SCHEDULE_ANIMATION, action); + } } - mHandler.removeMessages(MSG_POST_DELAYED_ANIMATION, runnable); } /** * Posts a callback to run on the next draw cycle. * The callback only runs once and then is automatically removed. * - * @param runnable The callback to run during the next draw cycle. + * @param action The callback action to run during the next draw cycle. + * @param token The callback token, or null if none. * * @see #removeDrawCallback */ - public void postDrawCallback(Runnable runnable) { - if (runnable == null) { - throw new IllegalArgumentException("runnable must not be null"); - } - postDrawCallbackUnchecked(runnable); - } - - private void postDrawCallbackUnchecked(Runnable runnable) { - synchronized (mLock) { - mDrawCallbacks = addCallbackLocked(mDrawCallbacks, runnable); - scheduleDrawLocked(); - } + public void postDrawCallback(Runnable action, Object token) { + postDrawCallbackDelayed(action, token, 0); } /** * Posts a callback to run on the next draw cycle following the specified delay. * The callback only runs once and then is automatically removed. * - * @param runnable The callback to run during the next draw cycle following + * @param action The callback action to run during the next animation cycle after * the specified delay. + * @param token The callback token, or null if none. * @param delayMillis The delay time in milliseconds. * * @see #removeDrawCallback */ - public void postDrawCallbackDelayed(Runnable runnable, long delayMillis) { - if (runnable == null) { - throw new IllegalArgumentException("runnable must not be null"); + public void postDrawCallbackDelayed(Runnable action, Object token, long delayMillis) { + if (action == null) { + throw new IllegalArgumentException("action must not be null"); } - if (delayMillis <= 0) { - postDrawCallbackUnchecked(runnable); - } else { - Message msg = mHandler.obtainMessage(MSG_POST_DELAYED_DRAW, runnable); - mHandler.sendMessageDelayed(msg, delayMillis); + + synchronized (mLock) { + final long now = SystemClock.uptimeMillis(); + final long dueTime = now + delayMillis; + mDrawCallbacks = addCallbackLocked(mDrawCallbacks, dueTime, action, token); + scheduleDrawLocked(now); + + if (dueTime <= now) { + scheduleDrawLocked(now); + } else { + Message msg = mHandler.obtainMessage(MSG_DO_SCHEDULE_DRAW, action); + mHandler.sendMessageAtTime(msg, dueTime); + } } } /** - * Removes draw callbacks for the specified runnable. - * Does nothing if the specified draw callback has not been posted or has already - * been removed. + * Removes draw callbacks that have the specified action and token. * - * @param runnable The draw callback to remove. + * @param action The action property of the callbacks to remove, or null to remove + * callbacks with any action. + * @param token The token property of the callbacks to remove, or null to remove + * callbacks with any token. * * @see #postDrawCallback * @see #postDrawCallbackDelayed */ - public void removeDrawCallbacks(Runnable runnable) { - if (runnable == null) { - throw new IllegalArgumentException("runnable must not be null"); - } + public void removeDrawCallbacks(Runnable action, Object token) { synchronized (mLock) { - mDrawCallbacks = removeCallbacksLocked(mDrawCallbacks, runnable); + mDrawCallbacks = removeCallbacksLocked(mDrawCallbacks, action, token); + if (action != null && token == null) { + mHandler.removeMessages(MSG_DO_SCHEDULE_DRAW, action); + } } - mHandler.removeMessages(MSG_POST_DELAYED_DRAW, runnable); } - private void scheduleAnimationLocked() { + private void scheduleAnimationLocked(long now) { if (!mAnimationScheduled) { mAnimationScheduled = true; if (USE_VSYNC) { @@ -291,14 +315,13 @@ public final class Choreographer { // otherwise post a message to schedule the vsync from the UI thread // as soon as possible. if (isRunningOnLooperThreadLocked()) { - doScheduleVsyncLocked(); + scheduleVsyncLocked(); } else { Message msg = mHandler.obtainMessage(MSG_DO_SCHEDULE_VSYNC); msg.setAsynchronous(true); mHandler.sendMessageAtFrontOfQueue(msg); } } else { - final long now = SystemClock.uptimeMillis(); final long nextAnimationTime = Math.max(mLastAnimationTime + sFrameDelay, now); if (DEBUG) { Log.d(TAG, "Scheduling animation in " + (nextAnimationTime - now) + " ms."); @@ -310,18 +333,18 @@ public final class Choreographer { } } - private void scheduleDrawLocked() { + private void scheduleDrawLocked(long now) { if (!mDrawScheduled) { mDrawScheduled = true; if (USE_ANIMATION_TIMER_FOR_DRAW) { - scheduleAnimationLocked(); + scheduleAnimationLocked(now); } else { if (DEBUG) { Log.d(TAG, "Scheduling draw immediately."); } Message msg = mHandler.obtainMessage(MSG_DO_DRAW); msg.setAsynchronous(true); - mHandler.sendMessage(msg); + mHandler.sendMessageAtTime(msg, now); } } } @@ -336,7 +359,7 @@ public final class Choreographer { void doAnimationInner() { final long start; - final Callback callbacks; + Callback callbacks; synchronized (mLock) { if (!mAnimationScheduled) { return; // no work to do @@ -351,7 +374,23 @@ public final class Choreographer { mLastAnimationTime = start; callbacks = mAnimationCallbacks; - mAnimationCallbacks = null; + if (callbacks != null) { + if (callbacks.dueTime > start) { + callbacks = null; + } else { + Callback predecessor = callbacks; + Callback successor = predecessor.next; + while (successor != null) { + if (successor.dueTime > start) { + predecessor.next = null; + break; + } + predecessor = successor; + successor = successor.next; + } + mAnimationCallbacks = successor; + } + } } if (callbacks != null) { @@ -368,7 +407,7 @@ public final class Choreographer { void doDraw() { final long start; - final Callback callbacks; + Callback callbacks; synchronized (mLock) { if (!mDrawScheduled) { return; // no work to do @@ -383,7 +422,23 @@ public final class Choreographer { mLastDrawTime = start; callbacks = mDrawCallbacks; - mDrawCallbacks = null; + if (callbacks != null) { + if (callbacks.dueTime > start) { + callbacks = null; + } else { + Callback predecessor = callbacks; + Callback successor = predecessor.next; + while (successor != null) { + if (successor.dueTime > start) { + predecessor.next = null; + break; + } + predecessor = successor; + successor = successor.next; + } + mDrawCallbacks = successor; + } + } } if (callbacks != null) { @@ -400,38 +455,66 @@ public final class Choreographer { void doScheduleVsync() { synchronized (mLock) { - doScheduleVsyncLocked(); + if (mAnimationScheduled) { + scheduleVsyncLocked(); + } } } - private void doScheduleVsyncLocked() { - if (mAnimationScheduled) { - mDisplayEventReceiver.scheduleVsync(); + void doScheduleAnimation() { + synchronized (mLock) { + final long now = SystemClock.uptimeMillis(); + if (mAnimationCallbacks != null && mAnimationCallbacks.dueTime <= now) { + scheduleAnimationLocked(now); + } } } + void doScheduleDraw() { + synchronized (mLock) { + final long now = SystemClock.uptimeMillis(); + if (mDrawCallbacks != null && mDrawCallbacks.dueTime <= now) { + scheduleDrawLocked(now); + } + } + } + + private void scheduleVsyncLocked() { + mDisplayEventReceiver.scheduleVsync(); + } + private boolean isRunningOnLooperThreadLocked() { return Looper.myLooper() == mLooper; } - private Callback addCallbackLocked(Callback head, Runnable runnable) { - Callback callback = obtainCallbackLocked(runnable); + private Callback addCallbackLocked(Callback head, + long dueTime, Runnable action, Object token) { + Callback callback = obtainCallbackLocked(dueTime, action, token); if (head == null) { return callback; } - Callback tail = head; - while (tail.next != null) { - tail = tail.next; + Callback entry = head; + if (dueTime < entry.dueTime) { + callback.next = entry; + return callback; + } + while (entry.next != null) { + if (dueTime < entry.next.dueTime) { + callback.next = entry.next; + break; + } + entry = entry.next; } - tail.next = callback; + entry.next = callback; return head; } - private Callback removeCallbacksLocked(Callback head, Runnable runnable) { + private Callback removeCallbacksLocked(Callback head, Runnable action, Object token) { Callback predecessor = null; for (Callback callback = head; callback != null;) { final Callback next = callback.next; - if (callback.runnable == runnable) { + if ((action == null || callback.action == action) + && (token == null || callback.token == token)) { if (predecessor != null) { predecessor.next = next; } else { @@ -448,7 +531,7 @@ public final class Choreographer { private void runCallbacks(Callback head) { while (head != null) { - head.runnable.run(); + head.action.run(); head = head.next; } } @@ -461,7 +544,7 @@ public final class Choreographer { } } - private Callback obtainCallbackLocked(Runnable runnable) { + private Callback obtainCallbackLocked(long dueTime, Runnable action, Object token) { Callback callback = mCallbackPool; if (callback == null) { callback = new Callback(); @@ -469,12 +552,15 @@ public final class Choreographer { mCallbackPool = callback.next; callback.next = null; } - callback.runnable = runnable; + callback.dueTime = dueTime; + callback.action = action; + callback.token = token; return callback; } private void recycleCallbackLocked(Callback callback) { - callback.runnable = null; + callback.action = null; + callback.token = null; callback.next = mCallbackPool; mCallbackPool = callback; } @@ -496,11 +582,11 @@ public final class Choreographer { case MSG_DO_SCHEDULE_VSYNC: doScheduleVsync(); break; - case MSG_POST_DELAYED_ANIMATION: - postAnimationCallbackUnchecked((Runnable)msg.obj); + case MSG_DO_SCHEDULE_ANIMATION: + doScheduleAnimation(); break; - case MSG_POST_DELAYED_DRAW: - postDrawCallbackUnchecked((Runnable)msg.obj); + case MSG_DO_SCHEDULE_DRAW: + doScheduleDraw(); break; } } @@ -519,6 +605,8 @@ public final class Choreographer { private static final class Callback { public Callback next; - public Runnable runnable; + public long dueTime; + public Runnable action; + public Object token; } } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b38ca5b..a651362 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8793,6 +8793,52 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal } /** + * <p>Causes the Runnable to execute on the next animation time step. + * The runnable will be run on the user interface thread.</p> + * + * <p>This method can be invoked from outside of the UI thread + * only when this View is attached to a window.</p> + * + * @param action The Runnable that will be executed. + * + * @hide + */ + public void postOnAnimation(Runnable action) { + final AttachInfo attachInfo = mAttachInfo; + if (attachInfo != null) { + attachInfo.mViewRootImpl.mChoreographer.postAnimationCallback(action, null); + } else { + // Assume that post will succeed later + ViewRootImpl.getRunQueue().post(action); + } + } + + /** + * <p>Causes the Runnable to execute on the next animation time step, + * after the specified amount of time elapses. + * The runnable will be run on the user interface thread.</p> + * + * <p>This method can be invoked from outside of the UI thread + * only when this View is attached to a window.</p> + * + * @param action The Runnable that will be executed. + * @param delayMillis The delay (in milliseconds) until the Runnable + * will be executed. + * + * @hide + */ + public void postOnAnimationDelayed(Runnable action, long delayMillis) { + final AttachInfo attachInfo = mAttachInfo; + if (attachInfo != null) { + attachInfo.mViewRootImpl.mChoreographer.postAnimationCallbackDelayed( + action, null, delayMillis); + } else { + // Assume that post will succeed later + ViewRootImpl.getRunQueue().postDelayed(action, delayMillis); + } + } + + /** * <p>Removes the specified Runnable from the message queue.</p> * * <p>This method can be invoked from outside of the UI thread @@ -8809,6 +8855,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal final AttachInfo attachInfo = mAttachInfo; if (attachInfo != null) { attachInfo.mHandler.removeCallbacks(action); + attachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(action, null); } else { // Assume that post will succeed later ViewRootImpl.getRunQueue().removeCallbacks(action); @@ -11880,10 +11927,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal */ public void scheduleDrawable(Drawable who, Runnable what, long when) { if (verifyDrawable(who) && what != null) { + final long delay = when - SystemClock.uptimeMillis(); if (mAttachInfo != null) { - mAttachInfo.mHandler.postAtTime(what, who, when); + mAttachInfo.mViewRootImpl.mChoreographer.postAnimationCallbackDelayed( + what, who, Choreographer.subtractFrameDelay(delay)); } else { - ViewRootImpl.getRunQueue().postDelayed(what, when - SystemClock.uptimeMillis()); + ViewRootImpl.getRunQueue().postDelayed(what, delay); } } } @@ -11897,7 +11946,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal public void unscheduleDrawable(Drawable who, Runnable what) { if (verifyDrawable(who) && what != null) { if (mAttachInfo != null) { - mAttachInfo.mHandler.removeCallbacks(what, who); + mAttachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(what, who); } else { ViewRootImpl.getRunQueue().removeCallbacks(what); } @@ -11915,7 +11964,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal */ public void unscheduleDrawable(Drawable who) { if (mAttachInfo != null) { - mAttachInfo.mHandler.removeCallbacksAndMessages(who); + mAttachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(null, who); } } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 9cde153..72365c7 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -884,7 +884,7 @@ public final class ViewRootImpl implements ViewParent, void scheduleFrame() { if (!mFrameScheduled) { mFrameScheduled = true; - mChoreographer.postDrawCallback(mFrameRunnable); + mChoreographer.postDrawCallback(mFrameRunnable, null); } } @@ -893,7 +893,7 @@ public final class ViewRootImpl implements ViewParent, if (mFrameScheduled) { mFrameScheduled = false; - mChoreographer.removeDrawCallbacks(mFrameRunnable); + mChoreographer.removeDrawCallbacks(mFrameRunnable, null); } } @@ -4051,7 +4051,7 @@ public final class ViewRootImpl implements ViewParent, } if (mPosted && mViews.isEmpty() && mViewRects.isEmpty()) { - mChoreographer.removeAnimationCallbacks(this); + mChoreographer.removeAnimationCallbacks(this, null); mPosted = false; } } @@ -4092,7 +4092,7 @@ public final class ViewRootImpl implements ViewParent, private void postIfNeededLocked() { if (!mPosted) { - mChoreographer.postAnimationCallback(this); + mChoreographer.postAnimationCallback(this, null); mPosted = true; } } diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index 334b9c4..23e55e2 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -169,6 +169,8 @@ public class Switch extends CompoundButton { /** * Sets the switch text color, size, style, hint color, and highlight color * from the specified TextAppearance resource. + * + * @attr ref android.R.styleable#Switch_switchTextAppearance */ public void setSwitchTextAppearance(Context context, int resid) { TypedArray appearance = @@ -274,7 +276,128 @@ public class Switch extends CompoundButton { } /** + * Set the amount of horizontal padding between the switch and the associated text. + * + * @param pixels Amount of padding in pixels + * + * @attr ref android.R.styleable#Switch_switchPadding + */ + public void setSwitchPadding(int pixels) { + mSwitchPadding = pixels; + requestLayout(); + } + + /** + * Get the amount of horizontal padding between the switch and the associated text. + * + * @return Amount of padding in pixels + * + * @attr ref android.R.styleable#Switch_switchPadding + */ + public int getSwitchPadding() { + return mSwitchPadding; + } + + /** + * Set the minimum width of the switch in pixels. The switch's width will be the maximum + * of this value and its measured width as determined by the switch drawables and text used. + * + * @param pixels Minimum width of the switch in pixels + * + * @attr ref android.R.styleable#Switch_switchMinWidth + */ + public void setSwitchMinWidth(int pixels) { + mSwitchMinWidth = pixels; + requestLayout(); + } + + /** + * Get the minimum width of the switch in pixels. The switch's width will be the maximum + * of this value and its measured width as determined by the switch drawables and text used. + * + * @return Minimum width of the switch in pixels + * + * @attr ref android.R.styleable#Switch_switchMinWidth + */ + public int getSwitchMinWidth() { + return mSwitchMinWidth; + } + + /** + * Set the horizontal padding around the text drawn on the switch itself. + * + * @param pixels Horizontal padding for switch thumb text in pixels + * + * @attr ref android.R.styleable#Switch_thumbTextPadding + */ + public void setThumbTextPadding(int pixels) { + mThumbTextPadding = pixels; + requestLayout(); + } + + /** + * Get the horizontal padding around the text drawn on the switch itself. + * + * @return Horizontal padding for switch thumb text in pixels + * + * @attr ref android.R.styleable#Switch_thumbTextPadding + */ + public int getThumbTextPadding() { + return mThumbTextPadding; + } + + /** + * Set the drawable used for the track that the switch slides within. + * + * @param track Track drawable + * + * @attr ref android.R.styleable#Switch_track + */ + public void setTrackDrawable(Drawable track) { + mTrackDrawable = track; + requestLayout(); + } + + /** + * Get the drawable used for the track that the switch slides within. + * + * @return Track drawable + * + * @attr ref android.R.styleable#Switch_track + */ + public Drawable getTrackDrawable() { + return mTrackDrawable; + } + + /** + * Set the drawable used for the switch "thumb" - the piece that the user + * can physically touch and drag along the track. + * + * @param thumb Thumb drawable + * + * @attr ref android.R.styleable#Switch_thumb + */ + public void setThumbDrawable(Drawable thumb) { + mThumbDrawable = thumb; + requestLayout(); + } + + /** + * Get the drawable used for the switch "thumb" - the piece that the user + * can physically touch and drag along the track. + * + * @return Thumb drawable + * + * @attr ref android.R.styleable#Switch_thumb + */ + public Drawable getThumbDrawable() { + return mThumbDrawable; + } + + /** * Returns the text displayed when the button is in the checked state. + * + * @attr ref android.R.styleable#Switch_textOn */ public CharSequence getTextOn() { return mTextOn; @@ -282,6 +405,8 @@ public class Switch extends CompoundButton { /** * Sets the text displayed when the button is in the checked state. + * + * @attr ref android.R.styleable#Switch_textOn */ public void setTextOn(CharSequence textOn) { mTextOn = textOn; @@ -290,6 +415,8 @@ public class Switch extends CompoundButton { /** * Returns the text displayed when the button is not in the checked state. + * + * @attr ref android.R.styleable#Switch_textOff */ public CharSequence getTextOff() { return mTextOff; @@ -297,6 +424,8 @@ public class Switch extends CompoundButton { /** * Sets the text displayed when the button is not in the checked state. + * + * @attr ref android.R.styleable#Switch_textOff */ public void setTextOff(CharSequence textOff) { mTextOff = textOff; diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 6a99a2b..998c037 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -348,6 +348,7 @@ public class ZygoteInit { TypedArray ar = mResources.obtainTypedArray( com.android.internal.R.array.preloaded_drawables); int N = preloadDrawables(runtime, ar); + ar.recycle(); Log.i(TAG, "...preloaded " + N + " resources in " + (SystemClock.uptimeMillis()-startTime) + "ms."); @@ -355,6 +356,7 @@ public class ZygoteInit { ar = mResources.obtainTypedArray( com.android.internal.R.array.preloaded_color_state_lists); N = preloadColorStateLists(runtime, ar); + ar.recycle(); Log.i(TAG, "...preloaded " + N + " resources in " + (SystemClock.uptimeMillis()-startTime) + "ms."); } diff --git a/core/res/res/values-es-rUS/strings.xml b/core/res/res/values-es-rUS/strings.xml index 1a0d479..8e36948 100644 --- a/core/res/res/values-es-rUS/strings.xml +++ b/core/res/res/values-es-rUS/strings.xml @@ -671,7 +671,7 @@ <string name="faceunlock_multiple_failures" msgid="754137583022792429">"Se superó el máximo de intentos permitido para el desbloqueo facial del dispositivo."</string> <string name="lockscreen_plugged_in" msgid="8057762828355572315">"Cargando <xliff:g id="NUMBER">%d</xliff:g><xliff:g id="PERCENT">%%</xliff:g>"</string> <string name="lockscreen_charged" msgid="4938930459620989972">"Cargada."</string> - <string name="lockscreen_battery_short" msgid="4477264849386850266">"<xliff:g id="NUMBER">%d</xliff:g> <xliff:g id="PERCENT">%%</xliff:g>"</string> + <string name="lockscreen_battery_short" msgid="4477264849386850266">"<xliff:g id="NUMBER">%d</xliff:g><xliff:g id="PERCENT">%%</xliff:g>"</string> <string name="lockscreen_low_battery" msgid="1482873981919249740">"Conecta tu cargador."</string> <string name="lockscreen_missing_sim_message_short" msgid="7381499217732227295">"No hay tarjeta SIM."</string> <string name="lockscreen_missing_sim_message" product="tablet" msgid="151659196095791474">"No hay tarjeta SIM en el tablet."</string> @@ -768,8 +768,8 @@ <string name="permdesc_serialPort" msgid="2991639985224598193">"Permite acceder a puertos serie a través de la API SerialManager."</string> <string name="permlab_accessContentProvidersExternally" msgid="5077774297943409285">"acceder a proveedores externamente"</string> <string name="permdesc_accessContentProvidersExternally" msgid="4544346486697853685">"Permite acceder a los proveedores de contenido desde la interfaz. Las aplicaciones normales nunca deberían necesitarlo."</string> - <string name="permlab_updateLock" msgid="3527558366616680889">"desalentar a las actualizaciones automáticas de dispositivos"</string> - <string name="permdesc_updateLock" msgid="1655625832166778492">"Permite a su titular a ofrecer información al sistema acerca de cuándo sería un buen momento para reiniciar el sistema no interactivo para actualizar el dispositivo."</string> + <string name="permlab_updateLock" msgid="3527558366616680889">"no realizar actualizaciones automáticas"</string> + <string name="permdesc_updateLock" msgid="1655625832166778492">"Permite a su propietario ofrecer información al sistema acerca de cuándo sería adecuado reiniciar el sistema de forma no interactiva y actualizar el dispositivo."</string> <string name="save_password_message" msgid="767344687139195790">"¿Quieres recordar esta contraseña en el navegador?"</string> <string name="save_password_notnow" msgid="6389675316706699758">"Ahora no."</string> <string name="save_password_remember" msgid="6491879678996749466">"Recuerda"</string> diff --git a/core/res/res/values-ms/strings.xml b/core/res/res/values-ms/strings.xml index 5bb95af..385bebb 100644 --- a/core/res/res/values-ms/strings.xml +++ b/core/res/res/values-ms/strings.xml @@ -769,7 +769,7 @@ <string name="permlab_accessContentProvidersExternally" msgid="5077774297943409285">"akses pembekal kandungan secara luaran"</string> <string name="permdesc_accessContentProvidersExternally" msgid="4544346486697853685">"Membolehkan pemegang mengakses pembekal kandungan dari luar. Tidak akan sekali-kali diperlukan untuk apl biasa."</string> <string name="permlab_updateLock" msgid="3527558366616680889">"tidak menggalakkan kemas kini peranti automatik"</string> - <string name="permdesc_updateLock" msgid="1655625832166778492">"Membenarkan pemegang untuk menawarkan maklumat kepada sistem tentang bila akan menjadi masa yang baik untuk but semula bukan interaktif untuk menaik taraf peranti."</string> + <string name="permdesc_updateLock" msgid="1655625832166778492">"Membenarkan aplikasi untuk menawarkan maklumat kepada sistem tentang bila akan menjadi masa yang baik untuk but semula bukan interaktif untuk menaik taraf peranti."</string> <string name="save_password_message" msgid="767344687139195790">"Adakah anda mahu penyemak imbas mengingati kata laluan ini?"</string> <string name="save_password_notnow" msgid="6389675316706699758">"Bukan sekarang"</string> <string name="save_password_remember" msgid="6491879678996749466">"Ingat"</string> diff --git a/core/res/res/values-nb/strings.xml b/core/res/res/values-nb/strings.xml index 6a9f846..e70a664 100644 --- a/core/res/res/values-nb/strings.xml +++ b/core/res/res/values-nb/strings.xml @@ -671,7 +671,7 @@ <string name="faceunlock_multiple_failures" msgid="754137583022792429">"Du har overskredet grensen for opplåsingsforsøk med Ansiktslås"</string> <string name="lockscreen_plugged_in" msgid="8057762828355572315">"Lader, <xliff:g id="NUMBER">%d</xliff:g><xliff:g id="PERCENT">%%</xliff:g>"</string> <string name="lockscreen_charged" msgid="4938930459620989972">"Fullt ladet"</string> - <string name="lockscreen_battery_short" msgid="4477264849386850266">"<xliff:g id="NUMBER">%d</xliff:g><xliff:g id="PERCENT">%%</xliff:g>"</string> + <string name="lockscreen_battery_short" msgid="4477264849386850266">"<xliff:g id="NUMBER">%d</xliff:g> <xliff:g id="PERCENT">%%</xliff:g>"</string> <string name="lockscreen_low_battery" msgid="1482873981919249740">"Koble til en batterilader."</string> <string name="lockscreen_missing_sim_message_short" msgid="7381499217732227295">"Mangler SIM-kort."</string> <string name="lockscreen_missing_sim_message" product="tablet" msgid="151659196095791474">"Nettbrettet mangler SIM-kort."</string> diff --git a/core/res/res/values-pl/strings.xml b/core/res/res/values-pl/strings.xml index 286c32c..96dcfa0 100644 --- a/core/res/res/values-pl/strings.xml +++ b/core/res/res/values-pl/strings.xml @@ -768,8 +768,8 @@ <string name="permdesc_serialPort" msgid="2991639985224598193">"Umożliwia posiadaczowi dostęp do portów szeregowych przy użyciu interfejsu API narzędzia SerialManager."</string> <string name="permlab_accessContentProvidersExternally" msgid="5077774297943409285">"Dostęp do dostawców treści z zewnątrz"</string> <string name="permdesc_accessContentProvidersExternally" msgid="4544346486697853685">"Pozwala na dostęp do dostawców treści z powłoki. To uprawnienie nie powinno być potrzebne zwykłym aplikacjom."</string> - <string name="permlab_updateLock" msgid="3527558366616680889">"odradź automatyczne aktualizacje urządzenia"</string> - <string name="permdesc_updateLock" msgid="1655625832166778492">"Umożliwia posiadaczowi poinformowanie systemu, kiedy będzie dobry moment na nieinteraktywne uruchomienie ponowne wymagane do uaktualnienia urządzenia."</string> + <string name="permlab_updateLock" msgid="3527558366616680889">"odradzanie automatycznych aktualizacji urządzenia"</string> + <string name="permdesc_updateLock" msgid="1655625832166778492">"Umożliwia posiadaczowi poinformowanie systemu, kiedy będzie dobry moment na ponowne uruchomienie wymagane do uaktualnienia urządzenia."</string> <string name="save_password_message" msgid="767344687139195790">"Czy chcesz, aby zapamiętać to hasło w przeglądarce?"</string> <string name="save_password_notnow" msgid="6389675316706699758">"Nie teraz"</string> <string name="save_password_remember" msgid="6491879678996749466">"Zapamiętaj"</string> diff --git a/core/res/res/values-sw/strings.xml b/core/res/res/values-sw/strings.xml index 286e6d6..13053ab 100644 --- a/core/res/res/values-sw/strings.xml +++ b/core/res/res/values-sw/strings.xml @@ -768,8 +768,8 @@ <string name="permdesc_serialPort" msgid="2991639985224598193">"Inaruhusu mmiliki kufikia vituo tambulishi kwa kutumia KisimamiziTambulishi cha API."</string> <string name="permlab_accessContentProvidersExternally" msgid="5077774297943409285">"fikia watoa huduma nje"</string> <string name="permdesc_accessContentProvidersExternally" msgid="4544346486697853685">"Inaruhusu mmiliki kufikia watoa huduma kutoka kwa onyesho. Haifai kuhitajika kamwe kwa programu za kawaida."</string> - <string name="permlab_updateLock" msgid="3527558366616680889">"katisha tamaa usasishaji kifaa kiotomatiki"</string> - <string name="permdesc_updateLock" msgid="1655625832166778492">"Inaruhusu mmiliki kutoa maelezo kwa mfumo kuhusu ni lini itakuwa wakati mzuri wa uwashaji upya usiotagusana ili kuboresha kifaa."</string> + <string name="permlab_updateLock" msgid="3527558366616680889">"pinga usasishaji kifaa kiotomatiki"</string> + <string name="permdesc_updateLock" msgid="1655625832166778492">"Inaruhusu mmiliki kutoa maelezo kwa mfumo kuhusu ni lini itakuwa wakati mzuri wa uwashaji upya usiotagusana ili kupandisha gredi kifaa."</string> <string name="save_password_message" msgid="767344687139195790">"Unataka kuvinjari ili ukumbuke nenosiri hili?"</string> <string name="save_password_notnow" msgid="6389675316706699758">"Si Sasa"</string> <string name="save_password_remember" msgid="6491879678996749466">"Kumbuka"</string> diff --git a/core/res/res/values-zh-rCN/strings.xml b/core/res/res/values-zh-rCN/strings.xml index 24b726d..2664ad3 100644 --- a/core/res/res/values-zh-rCN/strings.xml +++ b/core/res/res/values-zh-rCN/strings.xml @@ -769,7 +769,7 @@ <string name="permlab_accessContentProvidersExternally" msgid="5077774297943409285">"从外部访问内容提供程序"</string> <string name="permdesc_accessContentProvidersExternally" msgid="4544346486697853685">"允许持有者通过界面访问内容提供程序。普通应用绝不需要此权限。"</string> <string name="permlab_updateLock" msgid="3527558366616680889">"阻止自动设备更新"</string> - <string name="permdesc_updateLock" msgid="1655625832166778492">"允许持有人向系统提供相关信息,以确定什么时候适合执行非交互式重新启动来升级设备。"</string> + <string name="permdesc_updateLock" msgid="1655625832166778492">"允许应用向系统提供相关信息,以确定何时适合执行非交互式重启以升级设备。"</string> <string name="save_password_message" msgid="767344687139195790">"是否希望浏览器记住此密码?"</string> <string name="save_password_notnow" msgid="6389675316706699758">"暂不保存"</string> <string name="save_password_remember" msgid="6491879678996749466">"记住"</string> diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index d54ab35..cc0a594 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -185,7 +185,7 @@ public: audio_devices_t device); static uint32_t getStrategyForStream(audio_stream_type_t stream); - static uint32_t getDevicesForStream(audio_stream_type_t stream); + static audio_devices_t getDevicesForStream(audio_stream_type_t stream); static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); static status_t registerEffect(effect_descriptor_t *desc, diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h index bdd7747..04c927a 100644 --- a/include/media/IAudioPolicyService.h +++ b/include/media/IAudioPolicyService.h @@ -79,7 +79,7 @@ public: int *index, audio_devices_t device) = 0; virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0; - virtual uint32_t getDevicesForStream(audio_stream_type_t stream) = 0; + virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0; virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0; virtual status_t registerEffect(effect_descriptor_t *desc, audio_io_handle_t io, diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp index e0b186a..a1cbf0f 100644 --- a/media/libmedia/AudioSystem.cpp +++ b/media/libmedia/AudioSystem.cpp @@ -701,10 +701,10 @@ uint32_t AudioSystem::getStrategyForStream(audio_stream_type_t stream) return aps->getStrategyForStream(stream); } -uint32_t AudioSystem::getDevicesForStream(audio_stream_type_t stream) +audio_devices_t AudioSystem::getDevicesForStream(audio_stream_type_t stream) { const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service(); - if (aps == 0) return 0; + if (aps == 0) return (audio_devices_t)0; return aps->getDevicesForStream(stream); } diff --git a/media/libmedia/IAudioPolicyService.cpp b/media/libmedia/IAudioPolicyService.cpp index 99385aa4..da7c124 100644 --- a/media/libmedia/IAudioPolicyService.cpp +++ b/media/libmedia/IAudioPolicyService.cpp @@ -267,13 +267,13 @@ public: return reply.readInt32(); } - virtual uint32_t getDevicesForStream(audio_stream_type_t stream) + virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) { Parcel data, reply; data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor()); data.writeInt32(static_cast <uint32_t>(stream)); remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply); - return (uint32_t) reply.readInt32(); + return (audio_devices_t) reply.readInt32(); } virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index b21e86a..9e00bb3 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -2108,6 +2108,8 @@ status_t AwesomePlayer::finishSetDataSource_l() { mWVMExtractor = new WVMExtractor(dataSource); mWVMExtractor->setAdaptiveStreamingMode(true); + if (mUIDValid) + mWVMExtractor->setUID(mUID); extractor = mWVMExtractor; } else { extractor = MediaExtractor::Create( diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp index c7ad513..dac8106 100644 --- a/media/libstagefright/WVMExtractor.cpp +++ b/media/libstagefright/WVMExtractor.cpp @@ -123,6 +123,12 @@ void WVMExtractor::setAdaptiveStreamingMode(bool adaptive) { } } +void WVMExtractor::setUID(uid_t uid) { + if (mImpl != NULL) { + mImpl->setUID(uid); + } +} + bool SniffWVM( const sp<DataSource> &source, String8 *mimeType, float *confidence, sp<AMessage> *) { diff --git a/media/libstagefright/include/WVMExtractor.h b/media/libstagefright/include/WVMExtractor.h index 9f763f9..3c3ca89 100644 --- a/media/libstagefright/include/WVMExtractor.h +++ b/media/libstagefright/include/WVMExtractor.h @@ -34,6 +34,7 @@ public: virtual int64_t getCachedDurationUs(status_t *finalStatus) = 0; virtual void setAdaptiveStreamingMode(bool adaptive) = 0; + virtual void setUID(uid_t uid) = 0; }; class WVMExtractor : public MediaExtractor { @@ -60,6 +61,8 @@ public: // is used. void setAdaptiveStreamingMode(bool adaptive); + void setUID(uid_t uid); + static bool getVendorLibHandle(); protected: diff --git a/packages/SystemUI/res/values-in/strings.xml b/packages/SystemUI/res/values-in/strings.xml index 7c1cd18..1e82646 100644 --- a/packages/SystemUI/res/values-in/strings.xml +++ b/packages/SystemUI/res/values-in/strings.xml @@ -26,7 +26,7 @@ <string name="status_bar_recent_remove_item_title" msgid="6026395868129852968">"Hapus dari daftar"</string> <string name="status_bar_recent_inspect_item_title" msgid="7793624864528818569">"Info apl"</string> <string name="status_bar_no_recent_apps" msgid="6576392951053994640">"Tidak ada apl terbaru"</string> - <string name="status_bar_accessibility_dismiss_recents" msgid="4576076075226540105">"Singkirkan aplikasi terbaru"</string> + <string name="status_bar_accessibility_dismiss_recents" msgid="4576076075226540105">"Tutup aplikasi terbaru"</string> <plurals name="status_bar_accessibility_recent_apps"> <item quantity="one" msgid="5854176083865845541">"1 apl terbaru"</item> <item quantity="other" msgid="1040784359794890744">"%d apl terbaru"</item> diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp index 753b1d2..62768bf 100644 --- a/services/audioflinger/AudioPolicyService.cpp +++ b/services/audioflinger/AudioPolicyService.cpp @@ -432,10 +432,12 @@ uint32_t AudioPolicyService::getStrategyForStream(audio_stream_type_t stream) return mpAudioPolicy->get_strategy_for_stream(mpAudioPolicy, stream); } -uint32_t AudioPolicyService::getDevicesForStream(audio_stream_type_t stream) +//audio policy: use audio_device_t appropriately + +audio_devices_t AudioPolicyService::getDevicesForStream(audio_stream_type_t stream) { if (mpAudioPolicy == NULL) { - return 0; + return (audio_devices_t)0; } return mpAudioPolicy->get_devices_for_stream(mpAudioPolicy, stream); } diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h index 962c917..e41d51e 100644 --- a/services/audioflinger/AudioPolicyService.h +++ b/services/audioflinger/AudioPolicyService.h @@ -95,7 +95,7 @@ public: audio_devices_t device); virtual uint32_t getStrategyForStream(audio_stream_type_t stream); - virtual uint32_t getDevicesForStream(audio_stream_type_t stream); + virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream); virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); virtual status_t registerEffect(effect_descriptor_t *desc, diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index def22a9..18b51a7 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -9173,7 +9173,7 @@ public class WindowManagerService extends IWindowManager.Stub void scheduleAnimationLocked() { if (!mAnimationScheduled) { - mChoreographer.postAnimationCallback(mAnimationRunnable); + mChoreographer.postAnimationCallback(mAnimationRunnable, null); mAnimationScheduled = true; } } |
