diff options
90 files changed, 870 insertions, 597 deletions
diff --git a/CleanSpec.mk b/CleanSpec.mk index 228785975281..14b36819b674 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -136,6 +136,7 @@ $(call add-clean-step, rm -f $(PRODUCT_OUT)/system/media/video/Disco*) $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates) $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/ImageProcessing_intermediates) $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/ImageProcessing2_intermediates) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/ImageProcessing_intermediates) # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST # ************************************************ diff --git a/api/17.txt b/api/17.txt index 7b2f16120f78..ee9a9732a71c 100644 --- a/api/17.txt +++ b/api/17.txt @@ -29625,7 +29625,6 @@ package android.widget { method protected void onTextChanged(java.lang.CharSequence, int, int, int); method public boolean onTextContextMenuItem(int); method public void removeTextChangedListener(android.text.TextWatcher); - method protected void resetResolvedDrawables(); method public void setAllCaps(boolean); method public final void setAutoLinkMask(int); method public void setCompoundDrawablePadding(int); diff --git a/api/current.txt b/api/current.txt index 7b2f16120f78..ee9a9732a71c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -29625,7 +29625,6 @@ package android.widget { method protected void onTextChanged(java.lang.CharSequence, int, int, int); method public boolean onTextContextMenuItem(int); method public void removeTextChangedListener(android.text.TextWatcher); - method protected void resetResolvedDrawables(); method public void setAllCaps(boolean); method public final void setAutoLinkMask(int); method public void setCompoundDrawablePadding(int); diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index 0941d719882b..2bec1c176905 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -16,6 +16,7 @@ package android.os; +import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -91,7 +92,7 @@ public class FileUtils { } return result; } - + /** * Copy data from a source stream to destFile. * Return true if succeed, return false if failed. @@ -143,12 +144,16 @@ public class FileUtils { */ public static String readTextFile(File file, int max, String ellipsis) throws IOException { InputStream input = new FileInputStream(file); + // wrapping a BufferedInputStream around it because when reading /proc with unbuffered + // input stream, bytes read not equal to buffer size is not necessarily the correct + // indication for EOF; but it is true for BufferedInputStream due to its implementation. + BufferedInputStream bis = new BufferedInputStream(input); try { long size = file.length(); if (max > 0 || (size > 0 && max == 0)) { // "head" mode: read the first N bytes if (size > 0 && (max == 0 || size < max)) max = (int) size; byte[] data = new byte[max + 1]; - int length = input.read(data); + int length = bis.read(data); if (length <= 0) return ""; if (length <= max) return new String(data, 0, length); if (ellipsis == null) return new String(data, 0, max); @@ -161,7 +166,7 @@ public class FileUtils { if (last != null) rolled = true; byte[] tmp = last; last = data; data = tmp; if (data == null) data = new byte[-max]; - len = input.read(data); + len = bis.read(data); } while (len == data.length); if (last == null && len <= 0) return ""; @@ -178,12 +183,13 @@ public class FileUtils { int len; byte[] data = new byte[1024]; do { - len = input.read(data); + len = bis.read(data); if (len > 0) contents.write(data, 0, len); } while (len == data.length); return contents.toString(); } } finally { + bis.close(); input.close(); } } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 608bdd7c7e96..946965bc4e34 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -3666,15 +3666,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // Padding from the background drawable is stored at this point in mUserPaddingLeftInitial // and mUserPaddingRightInitial) so drawable padding will be used as ultimate default if // defined. - if (startPaddingDefined) { - mUserPaddingLeftInitial = startPadding; - } else if (leftPaddingDefined) { + if (leftPaddingDefined) { mUserPaddingLeftInitial = leftPadding; } - if (endPaddingDefined) { - mUserPaddingRightInitial = endPadding; - } - else if (rightPaddingDefined) { + if (rightPaddingDefined) { mUserPaddingRightInitial = rightPadding; } } @@ -11559,8 +11554,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Resolve all RTL related properties. + * + * @hide */ - void resolveRtlPropertiesIfNeeded() { + public void resolveRtlPropertiesIfNeeded() { if (!needRtlPropertiesResolution()) return; // Order is important here: LayoutDirection MUST be resolved first @@ -11584,8 +11581,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, onRtlPropertiesChanged(getLayoutDirection()); } - // Reset resolution of all RTL related properties. - void resetRtlProperties() { + /** + * Reset resolution of all RTL related properties. + * + * @hide + */ + public void resetRtlProperties() { resetResolvedLayoutDirection(); resetResolvedTextDirection(); resetResolvedTextAlignment(); @@ -14195,7 +14196,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @hide */ - public void resolveDrawables() { + protected void resolveDrawables() { if (mBackground != null) { mBackground.setLayoutDirection(getLayoutDirection()); } @@ -14218,7 +14219,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public void onResolveDrawables(int layoutDirection) { } - private void resetResolvedDrawables() { + /** + * @hide + */ + protected void resetResolvedDrawables() { mPrivateFlags2 &= ~PFLAG2_DRAWABLE_RESOLVED; } @@ -14804,14 +14808,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (isRtlCompatibilityMode()) { mPaddingLeft = mUserPaddingLeftInitial; mPaddingRight = mUserPaddingRightInitial; + return; + } + if (isLayoutRtl()) { + mPaddingLeft = (mUserPaddingEnd >= 0) ? mUserPaddingEnd : mUserPaddingLeftInitial; + mPaddingRight = (mUserPaddingStart >= 0) ? mUserPaddingStart : mUserPaddingRightInitial; } else { - if (isLayoutRtl()) { - mPaddingLeft = mUserPaddingRightInitial; - mPaddingRight = mUserPaddingLeftInitial; - } else { - mPaddingLeft = mUserPaddingLeftInitial; - mPaddingRight = mUserPaddingRightInitial; - } + mPaddingLeft = (mUserPaddingStart >= 0) ? mUserPaddingStart : mUserPaddingLeftInitial; + mPaddingRight = (mUserPaddingEnd >= 0) ? mUserPaddingEnd : mUserPaddingRightInitial; } } diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 0661992a1f0c..9ce7df943d9e 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -5263,6 +5263,21 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * @hide */ @Override + public void resolveRtlPropertiesIfNeeded() { + super.resolveRtlPropertiesIfNeeded(); + int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.isLayoutDirectionInherited()) { + child.resolveRtlPropertiesIfNeeded(); + } + } + } + + /** + * @hide + */ + @Override public boolean resolveLayoutDirection() { final boolean result = super.resolveLayoutDirection(); if (result) { @@ -5317,6 +5332,51 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * @hide */ @Override + public void resolvePadding() { + super.resolvePadding(); + int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.isLayoutDirectionInherited()) { + child.resolvePadding(); + } + } + } + + /** + * @hide + */ + @Override + protected void resolveDrawables() { + super.resolveDrawables(); + int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.isLayoutDirectionInherited()) { + child.resolveDrawables(); + } + } + } + + /** + * @hide + */ + @Override + public void resetRtlProperties() { + super.resetRtlProperties(); + int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.isLayoutDirectionInherited()) { + child.resetRtlProperties(); + } + } + } + + /** + * @hide + */ + @Override public void resetResolvedLayoutDirection() { super.resetResolvedLayoutDirection(); @@ -5362,6 +5422,38 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } /** + * @hide + */ + @Override + public void resetResolvedPadding() { + super.resetResolvedPadding(); + + int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.isLayoutDirectionInherited()) { + child.resetResolvedPadding(); + } + } + } + + /** + * @hide + */ + @Override + protected void resetResolvedDrawables() { + super.resetResolvedDrawables(); + + int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.isLayoutDirectionInherited()) { + child.resetResolvedDrawables(); + } + } + } + + /** * Return true if the pressed state should be delayed for children or descendants of this * ViewGroup. Generally, this should be done for containers that can scroll, such as a List. * This prevents the pressed state from appearing when the user is actually trying to scroll diff --git a/core/java/android/webkit/AccessibilityInjector.java b/core/java/android/webkit/AccessibilityInjector.java index 357a16ed6b0d..fe5cad44bfe8 100644 --- a/core/java/android/webkit/AccessibilityInjector.java +++ b/core/java/android/webkit/AccessibilityInjector.java @@ -97,9 +97,12 @@ class AccessibilityInjector { // Template for JavaScript that performs AndroidVox actions. private static final String ACCESSIBILITY_ANDROIDVOX_TEMPLATE = "(function() {" + - " if ((typeof(cvox) != 'undefined')"+ + " if ((typeof(cvox) != 'undefined')" + + " && (cvox != null)" + " && (typeof(cvox.ChromeVox) != 'undefined')" + + " && (cvox.ChromeVox != null)" + " && (typeof(cvox.AndroidVox) != 'undefined')" + + " && (cvox.AndroidVox != null)" + " && cvox.ChromeVox.isActive) {" + " return cvox.AndroidVox.performAction('%1s');" + " } else {" + @@ -110,9 +113,12 @@ class AccessibilityInjector { // JS code used to shut down an active AndroidVox instance. private static final String TOGGLE_CVOX_TEMPLATE = "javascript:(function() {" + - " if ((typeof(cvox) != 'undefined')"+ + " if ((typeof(cvox) != 'undefined')" + + " && (cvox != null)" + " && (typeof(cvox.ChromeVox) != 'undefined')" + - " && (typeof(cvox.ChromeVox.host) != 'undefined')) {" + + " && (cvox.ChromeVox != null)" + + " && (typeof(cvox.ChromeVox.host) != 'undefined')" + + " && (cvox.ChromeVox.host != null)) {" + " cvox.ChromeVox.host.activateOrDeactivateChromeVox(%b);" + " }" + "})();"; @@ -132,33 +138,60 @@ class AccessibilityInjector { } /** + * If JavaScript is enabled, pauses or resumes AndroidVox. + * + * @param enabled Whether feedback should be enabled. + */ + public void toggleAccessibilityFeedback(boolean enabled) { + if (!isAccessibilityEnabled() || !isJavaScriptEnabled()) { + return; + } + + toggleAndroidVox(enabled); + + if (!enabled && (mTextToSpeech != null)) { + mTextToSpeech.stop(); + } + } + + /** * Attempts to load scripting interfaces for accessibility. * <p> - * This should be called when the window is attached. - * </p> + * This should only be called before a page loads. */ - public void addAccessibilityApisIfNecessary() { + private void addAccessibilityApisIfNecessary() { if (!isAccessibilityEnabled() || !isJavaScriptEnabled()) { return; } addTtsApis(); addCallbackApis(); - toggleAndroidVox(true); } /** * Attempts to unload scripting interfaces for accessibility. * <p> - * This should be called when the window is detached. - * </p> + * This should only be called before a page loads. */ - public void removeAccessibilityApisIfNecessary() { - toggleAndroidVox(false); + private void removeAccessibilityApisIfNecessary() { removeTtsApis(); removeCallbackApis(); } + /** + * Destroys this accessibility injector. + */ + public void destroy() { + if (mTextToSpeech != null) { + mTextToSpeech.shutdown(); + mTextToSpeech = null; + } + + if (mCallback != null) { + mCallback = null; + } + } + private void toggleAndroidVox(boolean state) { if (!mAccessibilityScriptInjected) { return; @@ -517,7 +550,12 @@ class AccessibilityInjector { * settings. */ private boolean isJavaScriptEnabled() { - return mWebView.getSettings().getJavaScriptEnabled(); + final WebSettings settings = mWebView.getSettings(); + if (settings == null) { + return false; + } + + return settings.getJavaScriptEnabled(); } /** @@ -732,7 +770,7 @@ class AccessibilityInjector { private final String mInterfaceName; private boolean mResult = false; - private long mResultId = -1; + private int mResultId = -1; private CallbackHandler(String interfaceName) { mInterfaceName = interfaceName; @@ -784,34 +822,46 @@ class AccessibilityInjector { * @return Whether the result was received. */ private boolean waitForResultTimedLocked(int resultId) { - if (DEBUG) - Log.d(TAG, "Waiting for CVOX result..."); - long waitTimeMillis = RESULT_TIMEOUT; final long startTimeMillis = SystemClock.uptimeMillis(); + + if (DEBUG) + Log.d(TAG, "Waiting for CVOX result with ID " + resultId + "..."); + while (true) { + // Fail if we received a callback from the future. + if (mResultId > resultId) { + if (DEBUG) + Log.w(TAG, "Aborted CVOX result"); + return false; + } + + final long elapsedTimeMillis = (SystemClock.uptimeMillis() - startTimeMillis); + + // Succeed if we received the callback we were expecting. + if (DEBUG) + Log.w(TAG, "Check " + mResultId + " versus expected " + resultId); + if (mResultId == resultId) { + if (DEBUG) + Log.w(TAG, "Received CVOX result after " + elapsedTimeMillis + " ms"); + return true; + } + + final long waitTimeMillis = (RESULT_TIMEOUT - elapsedTimeMillis); + + // Fail if we've already exceeded the timeout. + if (waitTimeMillis <= 0) { + if (DEBUG) + Log.w(TAG, "Timed out while waiting for CVOX result"); + return false; + } + try { - if (mResultId == resultId) { - if (DEBUG) - Log.w(TAG, "Received CVOX result"); - return true; - } - if (mResultId > resultId) { - if (DEBUG) - Log.w(TAG, "Obsolete CVOX result"); - return false; - } - final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis; - waitTimeMillis = RESULT_TIMEOUT - elapsedTimeMillis; - if (waitTimeMillis <= 0) { - if (DEBUG) - Log.w(TAG, "Timed out while waiting for CVOX result"); - return false; - } + if (DEBUG) + Log.w(TAG, "Start waiting..."); mResultLock.wait(waitTimeMillis); } catch (InterruptedException ie) { if (DEBUG) Log.w(TAG, "Interrupted while waiting for CVOX result"); - /* ignore */ } } } @@ -827,11 +877,11 @@ class AccessibilityInjector { @SuppressWarnings("unused") public void onResult(String id, String result) { if (DEBUG) - Log.w(TAG, "Saw CVOX result of '" + result + "'"); - final long resultId; + Log.w(TAG, "Saw CVOX result of '" + result + "' for ID " + id); + final int resultId; try { - resultId = Long.parseLong(id); + resultId = Integer.parseInt(id); } catch (NumberFormatException e) { return; } @@ -840,6 +890,9 @@ class AccessibilityInjector { if (resultId > mResultId) { mResult = Boolean.parseBoolean(result); mResultId = resultId; + } else { + if (DEBUG) + Log.w(TAG, "Result with ID " + resultId + " was stale vesus " + mResultId); } mResultLock.notifyAll(); } diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java index 7d0d0bae525c..0f8966e2854b 100644 --- a/core/java/android/webkit/WebViewClassic.java +++ b/core/java/android/webkit/WebViewClassic.java @@ -2132,6 +2132,10 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc private void destroyJava() { mCallbackProxy.blockMessages(); + if (mAccessibilityInjector != null) { + mAccessibilityInjector.destroy(); + mAccessibilityInjector = null; + } if (mWebViewCore != null) { // Tell WebViewCore to destroy itself synchronized (this) { @@ -3967,8 +3971,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc // null, and that will be the case mWebView.setCertificate(null); - // reset the flag since we set to true in if need after - // loading is see onPageFinished(Url) if (isAccessibilityInjectionEnabled()) { getAccessibilityInjector().onPageStarted(url); } @@ -5397,7 +5399,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc if (mWebView.hasWindowFocus()) setActive(true); if (isAccessibilityInjectionEnabled()) { - getAccessibilityInjector().addAccessibilityApisIfNecessary(); + getAccessibilityInjector().toggleAccessibilityFeedback(true); } updateHwAccelerated(); @@ -5410,11 +5412,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc if (mWebView.hasWindowFocus()) setActive(false); if (isAccessibilityInjectionEnabled()) { - getAccessibilityInjector().removeAccessibilityApisIfNecessary(); - } else { - // Ensure the injector is cleared if we're detaching from the window - // and accessibility is disabled. - mAccessibilityInjector = null; + getAccessibilityInjector().toggleAccessibilityFeedback(false); } updateHwAccelerated(); diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java index e74e37c280b2..de8b80d45ec6 100644 --- a/core/java/android/widget/CheckedTextView.java +++ b/core/java/android/widget/CheckedTextView.java @@ -188,10 +188,11 @@ public class CheckedTextView extends TextView implements Checkable { resetPaddingToInitialValues(); int newPadding = (mCheckMarkDrawable != null) ? mCheckMarkWidth + mBasePadding : mBasePadding; - mNeedRequestlayout |= (mPaddingRight != newPadding); if (isLayoutRtl()) { + mNeedRequestlayout |= (mPaddingLeft != newPadding); mPaddingLeft = newPadding; } else { + mNeedRequestlayout |= (mPaddingRight != newPadding); mPaddingRight = newPadding; } if (mNeedRequestlayout) { @@ -200,18 +201,6 @@ public class CheckedTextView extends TextView implements Checkable { } } - @Override - public void setPadding(int left, int top, int right, int bottom) { - super.setPadding(left, top, right, bottom); - setBasePadding(isLayoutRtl()); - } - - @Override - public void setPaddingRelative(int start, int top, int end, int bottom) { - super.setPaddingRelative(start, top, end, bottom); - setBasePadding(isLayoutRtl()); - } - private void setBasePadding(boolean isLayoutRtl) { if (isLayoutRtl) { mBasePadding = mPaddingLeft; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 958b669f95b1..b3c679c34f84 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -8314,6 +8314,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } + /** + * @hide + */ protected void resetResolvedDrawables() { mResolvedDrawables = false; } diff --git a/core/java/com/android/internal/widget/RotarySelector.java b/core/java/com/android/internal/widget/RotarySelector.java index a2a38dcc9b51..4e405f4cd7e8 100644 --- a/core/java/com/android/internal/widget/RotarySelector.java +++ b/core/java/com/android/internal/widget/RotarySelector.java @@ -25,7 +25,9 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.drawable.Drawable; +import android.os.UserHandle; import android.os.Vibrator; +import android.provider.Settings; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; @@ -667,11 +669,16 @@ public class RotarySelector extends View { * Triggers haptic feedback. */ private synchronized void vibrate(long duration) { - if (mVibrator == null) { - mVibrator = (android.os.Vibrator) - getContext().getSystemService(Context.VIBRATOR_SERVICE); + final boolean hapticEnabled = Settings.System.getIntForUser( + mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1, + UserHandle.USER_CURRENT) != 0; + if (hapticEnabled) { + if (mVibrator == null) { + mVibrator = (android.os.Vibrator) getContext() + .getSystemService(Context.VIBRATOR_SERVICE); + } + mVibrator.vibrate(duration); } - mVibrator.vibrate(duration); } /** diff --git a/core/java/com/android/internal/widget/SlidingTab.java b/core/java/com/android/internal/widget/SlidingTab.java index f535a0844bfb..aebc4f6281e3 100644 --- a/core/java/com/android/internal/widget/SlidingTab.java +++ b/core/java/com/android/internal/widget/SlidingTab.java @@ -21,7 +21,9 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.os.UserHandle; import android.os.Vibrator; +import android.provider.Settings; import android.util.AttributeSet; import android.util.Log; import android.view.Gravity; @@ -811,11 +813,16 @@ public class SlidingTab extends ViewGroup { * Triggers haptic feedback. */ private synchronized void vibrate(long duration) { - if (mVibrator == null) { - mVibrator = (android.os.Vibrator) - getContext().getSystemService(Context.VIBRATOR_SERVICE); + final boolean hapticEnabled = Settings.System.getIntForUser( + mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1, + UserHandle.USER_CURRENT) != 0; + if (hapticEnabled) { + if (mVibrator == null) { + mVibrator = (android.os.Vibrator) getContext() + .getSystemService(Context.VIBRATOR_SERVICE); + } + mVibrator.vibrate(duration); } - mVibrator.vibrate(duration); } /** diff --git a/core/java/com/android/internal/widget/WaveView.java b/core/java/com/android/internal/widget/WaveView.java index 2d89234000a7..d33d50cc0c42 100644 --- a/core/java/com/android/internal/widget/WaveView.java +++ b/core/java/com/android/internal/widget/WaveView.java @@ -25,7 +25,9 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; +import android.os.UserHandle; import android.os.Vibrator; +import android.provider.Settings; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; @@ -573,11 +575,16 @@ public class WaveView extends View implements ValueAnimator.AnimatorUpdateListen * Triggers haptic feedback. */ private synchronized void vibrate(long duration) { - if (mVibrator == null) { - mVibrator = (android.os.Vibrator) - getContext().getSystemService(Context.VIBRATOR_SERVICE); + final boolean hapticEnabled = Settings.System.getIntForUser( + mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1, + UserHandle.USER_CURRENT) != 0; + if (hapticEnabled) { + if (mVibrator == null) { + mVibrator = (android.os.Vibrator) getContext() + .getSystemService(Context.VIBRATOR_SERVICE); + } + mVibrator.vibrate(duration); } - mVibrator.vibrate(duration); } /** diff --git a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java index f507a795172b..0f49776330a2 100644 --- a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java +++ b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java @@ -31,7 +31,9 @@ import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.UserHandle; import android.os.Vibrator; +import android.provider.Settings; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; @@ -543,7 +545,10 @@ public class GlowPadView extends View { } private void vibrate() { - if (mVibrator != null) { + final boolean hapticEnabled = Settings.System.getIntForUser( + mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1, + UserHandle.USER_CURRENT) != 0; + if (mVibrator != null && hapticEnabled) { mVibrator.vibrate(mVibrationDuration); } } diff --git a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java index 7990b4c75640..e22d1e8d43ba 100644 --- a/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java +++ b/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java @@ -32,7 +32,9 @@ import android.graphics.Canvas; import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.UserHandle; import android.os.Vibrator; +import android.provider.Settings; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; @@ -593,7 +595,10 @@ public class MultiWaveView extends View { } private void vibrate() { - if (mVibrator != null) { + final boolean hapticEnabled = Settings.System.getIntForUser( + mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1, + UserHandle.USER_CURRENT) != 0; + if (mVibrator != null && hapticEnabled) { mVibrator.vibrate(mVibrationDuration); } } diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index 1bba5b434477..fd7a6a757a35 100644 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -145,7 +145,7 @@ static void ToColor_S4444_Alpha(SkColor dst[], const void* src, int width, static void ToColor_S4444_Opaque(SkColor dst[], const void* src, int width,
SkColorTable*) {
SkASSERT(width > 0);
- const SkPMColor* s = (const SkPMColor*)src;
+ const SkPMColor16* s = (const SkPMColor16*)src;
do {
SkPMColor c = SkPixel4444ToPixel32(*s++);
*dst++ = SkColorSetRGB(SkGetPackedR32(c), SkGetPackedG32(c),
diff --git a/core/res/res/layout-land/keyguard_glow_pad_container.xml b/core/res/res/layout-land/keyguard_glow_pad_container.xml new file mode 100644 index 000000000000..f8364f1ee411 --- /dev/null +++ b/core/res/res/layout-land/keyguard_glow_pad_container.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 2012, 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. +*/ +--> + +<merge xmlns:android="http://schemas.android.com/apk/res/android"> + <include layout="@layout/keyguard_glow_pad_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" /> +</merge>
\ No newline at end of file diff --git a/core/res/res/layout-port/keyguard_host_view.xml b/core/res/res/layout-port/keyguard_host_view.xml index 3ce9365af092..20726d0050bb 100644 --- a/core/res/res/layout-port/keyguard_host_view.xml +++ b/core/res/res/layout-port/keyguard_host_view.xml @@ -29,15 +29,14 @@ <include layout="@layout/keyguard_widget_region" android:layout_width="match_parent" - android:layout_height="0dip" - android:layout_weight="27" /> + android:layout_height="153dp" /> <com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper android:id="@+id/view_flipper" android:layout_height="0dp" android:clipChildren="false" android:clipToPadding="false" - android:layout_weight="73" + android:layout_weight="1" android:paddingLeft="@dimen/keyguard_security_view_margin" android:paddingTop="@dimen/keyguard_security_view_margin" android:paddingRight="@dimen/keyguard_security_view_margin" diff --git a/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml b/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml index 4f94f96aed7f..47d4728a8290 100644 --- a/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml +++ b/core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml @@ -89,7 +89,6 @@ android:layout_weight="1" android:gravity="center" android:layout_gravity="center" - android:layout_marginStart="@dimen/keyguard_lockscreen_pin_margin_left" android:singleLine="true" android:textStyle="normal" android:inputType="textPassword" diff --git a/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml b/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml index 9a649fbb8d7e..6dd85cbc08de 100644 --- a/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml +++ b/core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml @@ -93,7 +93,6 @@ android:inputType="textPassword" android:gravity="center" android:layout_gravity="center" - android:layout_marginStart="@dimen/keyguard_lockscreen_pin_margin_left" android:textSize="24sp" android:textAppearance="?android:attr/textAppearanceMedium" android:background="@null" diff --git a/core/res/res/layout/keyguard_emergency_carrier_area.xml b/core/res/res/layout/keyguard_emergency_carrier_area.xml index c16955c120ac..f9a593fd5038 100644 --- a/core/res/res/layout/keyguard_emergency_carrier_area.xml +++ b/core/res/res/layout/keyguard_emergency_carrier_area.xml @@ -23,7 +23,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:gravity="center_horizontal" + android:gravity="center" android:layout_gravity="center_horizontal" android:layout_alignParentBottom="true"> diff --git a/core/res/res/layout/keyguard_glow_pad_container.xml b/core/res/res/layout/keyguard_glow_pad_container.xml index f8364f1ee411..376d0e935368 100644 --- a/core/res/res/layout/keyguard_glow_pad_container.xml +++ b/core/res/res/layout/keyguard_glow_pad_container.xml @@ -21,5 +21,6 @@ <include layout="@layout/keyguard_glow_pad_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center" /> + android:layout_gravity="bottom|center_horizontal" + android:layout_marginBottom="-80dp"/> </merge>
\ No newline at end of file diff --git a/core/res/res/layout/keyguard_password_view.xml b/core/res/res/layout/keyguard_password_view.xml index 92a755150553..ab8aa85ba55c 100644 --- a/core/res/res/layout/keyguard_password_view.xml +++ b/core/res/res/layout/keyguard_password_view.xml @@ -26,11 +26,12 @@ <FrameLayout android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="0dp" + android:layout_weight="1"> <LinearLayout android:layout_height="wrap_content" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:orientation="vertical" android:layout_gravity="center"> @@ -114,14 +115,14 @@ android:clickable="true" /> </LinearLayout> - - <include layout="@layout/keyguard_emergency_carrier_area" - android:id="@+id/keyguard_selector_fade_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:layout_gravity="bottom|center_horizontal" - android:gravity="center_horizontal" /> </LinearLayout> </FrameLayout> + <include layout="@layout/keyguard_emergency_carrier_area" + android:id="@+id/keyguard_selector_fade_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:layout_gravity="bottom|center_horizontal" + android:gravity="center_horizontal" /> + </com.android.internal.policy.impl.keyguard.KeyguardPasswordView> diff --git a/core/res/res/layout/keyguard_screen_password_landscape.xml b/core/res/res/layout/keyguard_screen_password_landscape.xml index e0a3ce3c13c0..80d9d61a007e 100644 --- a/core/res/res/layout/keyguard_screen_password_landscape.xml +++ b/core/res/res/layout/keyguard_screen_password_landscape.xml @@ -143,7 +143,6 @@ android:layout_width="0dip" android:layout_weight="1" android:gravity="center" - android:layout_marginStart="@dimen/keyguard_lockscreen_pin_margin_left" android:layout_gravity="center_vertical" android:singleLine="true" android:textStyle="normal" diff --git a/core/res/res/layout/keyguard_screen_password_portrait.xml b/core/res/res/layout/keyguard_screen_password_portrait.xml index 0212f737c034..3d61bae5f8fb 100644 --- a/core/res/res/layout/keyguard_screen_password_portrait.xml +++ b/core/res/res/layout/keyguard_screen_password_portrait.xml @@ -106,12 +106,10 @@ android:layout_marginEnd="16dip"> <EditText android:id="@+id/passwordEntry" - android:layout_width="0dip" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_weight="1" android:gravity="center_horizontal" android:layout_gravity="center_vertical" - android:layout_marginStart="@dimen/keyguard_lockscreen_pin_margin_left" android:singleLine="true" android:textStyle="normal" android:inputType="textPassword" diff --git a/core/res/res/layout/keyguard_selector_view.xml b/core/res/res/layout/keyguard_selector_view.xml index 4838c2acf7f2..daaf35bcdf5e 100644 --- a/core/res/res/layout/keyguard_selector_view.xml +++ b/core/res/res/layout/keyguard_selector_view.xml @@ -41,10 +41,8 @@ <include layout="@layout/keyguard_emergency_carrier_area" android:id="@+id/keyguard_selector_fade_container" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:layout_gravity="bottom|center_horizontal" - android:gravity="center_horizontal" /> + android:layout_height="48dp" + android:layout_gravity="bottom|center_horizontal" /> </FrameLayout> </com.android.internal.policy.impl.keyguard.KeyguardSelectorView> diff --git a/core/res/res/layout/keyguard_status_view.xml b/core/res/res/layout/keyguard_status_view.xml index a462c5426f85..1de0f6ccad80 100644 --- a/core/res/res/layout/keyguard_status_view.xml +++ b/core/res/res/layout/keyguard_status_view.xml @@ -33,28 +33,32 @@ android:gravity="center_horizontal|top" android:contentDescription="@*android:string/keyguard_accessibility_status"> - <com.android.internal.policy.impl.keyguard.ClockView - android:id="@+id/clock_view" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="@dimen/kg_clock_top_margin" - android:layout_marginEnd="@dimen/kg_status_line_font_right_margin" - android:layout_gravity="right"> - - <TextView android:id="@+id/clock_text" + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:orientation="vertical"> + <com.android.internal.policy.impl.keyguard.ClockView + android:id="@+id/clock_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:singleLine="true" - android:ellipsize="none" - android:textSize="@dimen/kg_status_clock_font_size" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textColor="#ffffffff" - android:drawablePadding="2dip" - /> + android:layout_marginEnd="@dimen/kg_status_line_font_right_margin" + android:layout_gravity="right"> + + <TextView android:id="@+id/clock_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:singleLine="true" + android:ellipsize="none" + android:textSize="@dimen/kg_status_clock_font_size" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="#ffffffff" + android:drawablePadding="2dip" + /> - </com.android.internal.policy.impl.keyguard.ClockView> + </com.android.internal.policy.impl.keyguard.ClockView> - <include layout="@layout/keyguard_status_area" /> + <include layout="@layout/keyguard_status_area" /> + </LinearLayout> </com.android.internal.policy.impl.keyguard.KeyguardStatusView> </com.android.internal.policy.impl.keyguard.KeyguardWidgetFrame> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 31d4ad7275e9..948a3d3c40c8 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -291,10 +291,10 @@ <dimen name="kg_widget_pager_horizontal_padding">16dp</dimen> <!-- Top padding for the widget pager --> - <dimen name="kg_widget_pager_top_padding">16dp</dimen> + <dimen name="kg_widget_pager_top_padding">0dp</dimen> <!-- Bottom padding for the widget pager --> - <dimen name="kg_widget_pager_bottom_padding">6dp</dimen> + <dimen name="kg_widget_pager_bottom_padding">0dp</dimen> <!-- Top margin for the runway lights. We add a negative margin in large devices to account for the widget pager padding --> diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs index e812ccbc7b25..46c4398c0699 100644 --- a/docs/html/guide/guide_toc.cs +++ b/docs/html/guide/guide_toc.cs @@ -191,28 +191,21 @@ <li><a href="<?cs var:toroot ?>guide/topics/ui/menus.html"> <span class="en">Menus</span></span> </a></li> - <li><a href="<?cs var:toroot ?>guide/topics/ui/dialogs.html"> - <span class="en">Dialogs</span> - </a></li> <li><a href="<?cs var:toroot ?>guide/topics/ui/actionbar.html"> <span class="en">Action Bar</span> </a></li> <li><a href="<?cs var:toroot ?>guide/topics/ui/settings.html"> <span class="en">Settings</span> </a></li> - <li class="nav-section"> - <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/index.html"> - <span class="en">Notifications</span> - </a></div> - <ul> - <li><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/toasts.html"> - <span class="en">Toast Notifications</span> - </a></li> - <li><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/notifications.html"> - <span class="en">Status Notifications</span> - </a></li> - </ul> - </li> + <li><a href="<?cs var:toroot ?>guide/topics/ui/dialogs.html"> + <span class="en">Dialogs</span> + </a></li> + <li><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/notifications.html"> + <span class="en">Notifications</span> + </a></li> + <li><a href="<?cs var:toroot ?>guide/topics/ui/notifiers/toasts.html"> + <span class="en">Toasts</span> + </a></li> <li class="nav-section"> <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/search/index.html"> <span class="en">Search</span> diff --git a/docs/html/guide/topics/ui/notifiers/notifications.jd b/docs/html/guide/topics/ui/notifiers/notifications.jd index fbff532dc165..2de62607ed0d 100644 --- a/docs/html/guide/topics/ui/notifiers/notifications.jd +++ b/docs/html/guide/topics/ui/notifiers/notifications.jd @@ -4,26 +4,43 @@ page.title=Notifications <div id="qv-wrapper"> <div id="qv"> <h2>In this document</h2> +<ol> + <li><a href="#NotificationUI">Notification Display Elements</a> <ol> - <li> - <a href="#NotificationUI">Notification Display Elements</a> - </li> - <li> - <a href="#CreateNotification">Creating a Notification</a> - </li> - <li> - <a href="#Managing">Managing Notifications</a> - </li> - <li> - <a href="#NotificationResponse">Preserving Navigation when Starting an Activity</a> - </li> - <li> - <a href="#Progress">Displaying Progress in a Notification</a> - </li> - <li> - <a href="#CustomNotification">Custom Notification Layouts</a> - </li> + <li><a href="#NormalNotify">Normal view</a></li> + <li><a href="#BigNotify">Big view</a></li> + </ol> + </li> + <li><a href="#CreateNotification">Creating a Notification</a> + <ol> + <li><a href="#Required">Required notification contents</a></li> + <li><a href="#Optional">Optional notification contents and settings</a></li> + <li><a href="#Actions">Notification actions</a></li> + <li><a href="#SimpleNotification">Creating a simple notification</a></li> + <li><a href="#ApplyStyle">Applying a big view style to a notification</a></li> + </ol> + </li> + <li><a href="#Managing">Managing Notifications</a> + <ol> + <li><a href="#Updating">Updating notifications</a></li> + <li><a href="#Removing">Removing notifications</a></li> + </ol> + </li> + <li><a href="#NotificationResponse">Preserving Navigation when Starting an Activity</a> + <ol> + <li><a href="#DirectEntry">Setting up a regular activity PendingIntent</a></li> + <li><a href="#ExtendedNotification">Setting up a special activity PendingIntent</a></li> + </ol> + </li> + <li><a href="#Progress">Displaying Progress in a Notification</a> + <ol> + <li><a href="#FixedProgress">Displaying a fixed-duration progress indicator</a></li> + <li><a href="#ActivityIndicator">Displaying a continuing activity indicator</a></li> </ol> + </li> + <li><a href="#CustomNotification">Custom Notification Layouts</a></li> +</ol> + <h2>Key classes</h2> <ol> <li>{@link android.app.NotificationManager}</li> @@ -54,13 +71,12 @@ page.title=Notifications <img id="figure1" src="{@docRoot}images/ui/notifications/iconic_notification.png" - height="32" - alt="" /> + height="120" alt="" /> <p class="img-caption"> <strong>Figure 1.</strong> Notifications in the notification area. </p> <img id="figure2" src="{@docRoot}images/ui/notifications/normal_notification.png" - height="240" alt="" /> + height="293" alt="" /> <p class="img-caption"> <strong>Figure 2.</strong> Notifications in the notification drawer. </p> @@ -98,7 +114,7 @@ page.title=Notifications <img src="{@docRoot}images/ui/notifications/normal_notification_callouts.png" alt="" - height="204" + height="153" id="figure3" /> <p class="img-caption"> <strong>Figure 3.</strong> Notification in normal view. diff --git a/docs/html/guide/topics/ui/notifiers/toasts.jd b/docs/html/guide/topics/ui/notifiers/toasts.jd index 1a1fb1ff875b..92c146a742ae 100644 --- a/docs/html/guide/topics/ui/notifiers/toasts.jd +++ b/docs/html/guide/topics/ui/notifiers/toasts.jd @@ -1,17 +1,8 @@ -page.title=Toast Notifications -parent.title=Notifications -parent.link=index.html +page.title=Toasts @jd:body <div id="qv-wrapper"> - <div id="qv"> - <h2>Quickview</h2> - <ol> - <li>A toast is a message that appears on the surface of the screen for a moment, but it -does not take focus (or pause the current activity), so it cannot accept user input</li> - <li>You can customize the toast layout to include images</li> - </ol> - + <div id="qv"> <h2>In this document</h2> <ol> <li><a href="#Basics">The Basics</a></li> @@ -26,22 +17,17 @@ does not take focus (or pause the current activity), so it cannot accept user in </div> </div> -<p>A toast notification is a message that pops up on the surface of the window. -It only fills the amount of space required for the message and the user's current -activity remains visible and interactive. The notification automatically fades in and -out, and does not accept interaction events.</p> +<p>A toast provides simple feedback about an operation in a small popup. +It only fills the amount of space required for the message and the current +activity remains visible and interactive. +For example, navigating away from an email before you send it triggers a +"Draft saved" toast to let you know that you can continue editing later. +Toasts automatically disappear after a timeout.</p> -<p>The screenshot below shows an example toast notification from the Alarm application. -Once an alarm is turned on, a toast is displayed to assure you that the -alarm was set.</p> <img src="{@docRoot}images/toast.png" alt="" /> -<p>A toast can be created and displayed from an {@link android.app.Activity} or -{@link android.app.Service}. If you create a toast notification from a Service, it -appears in front of the Activity currently in focus.</p> - -<p>If user response to the notification is required, consider using a -<a href="notifications.html">Status Bar Notification</a>.</p> +<p>If user response to a status message is required, consider instead using a +<a href="{@docRoot}guide/topics/ui/notifiers/notifications.html">Notification</a>.</p> <h2 id="Basics">The Basics</h2> @@ -90,8 +76,6 @@ To nudge it down, increase the value of the last parameter. <h2 id="CustomToastView">Creating a Custom Toast View</h2> -<img src="{@docRoot}images/custom_toast.png" alt="" style="float:right" /> - <p>If a simple text message isn't enough, you can create a customized layout for your toast notification. To create a custom layout, define a View layout, in XML or in your application code, and pass the root {@link android.view.View} object @@ -105,17 +89,17 @@ with the following XML (saved as <em>toast_layout.xml</em>):</p> android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:padding="10dp" + android:padding="8dp" android:background="#DAAA" > - <ImageView android:id="@+id/image" + <ImageView android:src="@drawable/droid" android:layout_width="wrap_content" - android:layout_height="fill_parent" - android:layout_marginRight="10dp" + android:layout_height="wrap_content" + android:layout_marginRight="8dp" /> <TextView android:id="@+id/text" android:layout_width="wrap_content" - android:layout_height="fill_parent" + android:layout_height="wrap_content" android:textColor="#FFF" /> </LinearLayout> @@ -126,13 +110,11 @@ ID to inflate the layout from the XML, as shown here:</p> <pre> LayoutInflater inflater = getLayoutInflater(); -View layout = inflater.inflate(R.layout.toast_layout, +View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout_root)); -ImageView image = (ImageView) layout.findViewById(R.id.image); -image.setImageResource(R.drawable.android); TextView text = (TextView) layout.findViewById(R.id.text); -text.setText("Hello! This is a custom toast!"); +text.setText("This is a custom toast"); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); diff --git a/docs/html/images/toast.png b/docs/html/images/toast.png Binary files differindex 223048a39614..b4c709ac2b48 100644 --- a/docs/html/images/toast.png +++ b/docs/html/images/toast.png diff --git a/docs/html/images/ui/notifications/iconic_notification.png b/docs/html/images/ui/notifications/iconic_notification.png Binary files differindex 4cabfdbe0a44..e72fe4e86b1b 100644 --- a/docs/html/images/ui/notifications/iconic_notification.png +++ b/docs/html/images/ui/notifications/iconic_notification.png diff --git a/docs/html/images/ui/notifications/normal_notification.png b/docs/html/images/ui/notifications/normal_notification.png Binary files differindex 3cf02311be4c..9bea5fb5196d 100644 --- a/docs/html/images/ui/notifications/normal_notification.png +++ b/docs/html/images/ui/notifications/normal_notification.png diff --git a/docs/html/images/ui/notifications/normal_notification_callouts.png b/docs/html/images/ui/notifications/normal_notification_callouts.png Binary files differindex db57dafbe0f2..6880e90c0f96 100644 --- a/docs/html/images/ui/notifications/normal_notification_callouts.png +++ b/docs/html/images/ui/notifications/normal_notification_callouts.png diff --git a/graphics/java/android/renderscript/ScriptGroup.java b/graphics/java/android/renderscript/ScriptGroup.java index 8943f7529b9a..7afdb3976398 100644 --- a/graphics/java/android/renderscript/ScriptGroup.java +++ b/graphics/java/android/renderscript/ScriptGroup.java @@ -77,7 +77,6 @@ public final class ScriptGroup extends BaseObj { ArrayList<Script.KernelID> mKernels = new ArrayList<Script.KernelID>(); ArrayList<ConnectLine> mInputs = new ArrayList<ConnectLine>(); ArrayList<ConnectLine> mOutputs = new ArrayList<ConnectLine>(); - boolean mSeen; int dagNumber; Node mNext; @@ -176,39 +175,24 @@ public final class ScriptGroup extends BaseObj { mRS = rs; } - private void validateCycleRecurse(Node n, int depth) { - n.mSeen = true; - - //android.util.Log.v("RSR", " validateCycleRecurse outputCount " + n.mOutputs.size()); - for (int ct=0; ct < n.mOutputs.size(); ct++) { - final ConnectLine cl = n.mOutputs.get(ct); + // do a DFS from original node, looking for original node + // any cycle that could be created must contain original node + private void validateCycle(Node target, Node original) { + for (int ct = 0; ct < target.mOutputs.size(); ct++) { + final ConnectLine cl = target.mOutputs.get(ct); if (cl.mToK != null) { Node tn = findNode(cl.mToK.mScript); - if (tn.mSeen) { + if (tn.equals(original)) { throw new RSInvalidStateException("Loops in group not allowed."); } - validateCycleRecurse(tn, depth + 1); + validateCycle(tn, original); } if (cl.mToF != null) { Node tn = findNode(cl.mToF.mScript); - if (tn.mSeen) { + if (tn.equals(original)) { throw new RSInvalidStateException("Loops in group not allowed."); } - validateCycleRecurse(tn, depth + 1); - } - } - } - - private void validateCycle() { - //android.util.Log.v("RSR", "validateCycle"); - - for (int ct=0; ct < mNodes.size(); ct++) { - for (int ct2=0; ct2 < mNodes.size(); ct2++) { - mNodes.get(ct2).mSeen = false; - } - Node n = mNodes.get(ct); - if (n.mInputs.size() == 0) { - validateCycleRecurse(n, 0); + validateCycle(tn, original); } } } @@ -327,7 +311,7 @@ public final class ScriptGroup extends BaseObj { Node nf = findNode(from); if (nf == null) { - throw new RSInvalidStateException("From kernel not found."); + throw new RSInvalidStateException("From script not found."); } Node nt = findNode(to.mScript); @@ -341,7 +325,7 @@ public final class ScriptGroup extends BaseObj { nf.mOutputs.add(cl); nt.mInputs.add(cl); - validateCycle(); + validateCycle(nf, nf); return this; } @@ -362,7 +346,7 @@ public final class ScriptGroup extends BaseObj { Node nf = findNode(from); if (nf == null) { - throw new RSInvalidStateException("From kernel not found."); + throw new RSInvalidStateException("From script not found."); } Node nt = findNode(to); @@ -376,7 +360,7 @@ public final class ScriptGroup extends BaseObj { nf.mOutputs.add(cl); nt.mInputs.add(cl); - validateCycle(); + validateCycle(nf, nf); return this; } diff --git a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java index 2cf795d83294..87d56fd79e49 100644 --- a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java +++ b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java @@ -42,16 +42,7 @@ public class FusionEngine implements LocationListener { private static final String NETWORK = LocationManager.NETWORK_PROVIDER; private static final String GPS = LocationManager.GPS_PROVIDER; - // threshold below which a location is considered stale enough - // that we shouldn't use its bearing, altitude, speed etc - private static final double WEIGHT_THRESHOLD = 0.5; - // accuracy in meters at which a Location's weight is halved (compared to 0 accuracy) - private static final double ACCURACY_HALFLIFE_M = 20.0; - // age in seconds at which a Location's weight is halved (compared to 0 age) - private static final double AGE_HALFLIFE_S = 60.0; - - private static final double ACCURACY_DECAY_CONSTANT_M = Math.log(2) / ACCURACY_HALFLIFE_M; - private static final double AGE_DECAY_CONSTANT_S = Math.log(2) / AGE_HALFLIFE_S; + public static final long SWITCH_ON_FRESHNESS_CLIFF_NS = 11 * 1000000000; // 11 seconds private final Context mContext; private final LocationManager mLocationManager; @@ -62,8 +53,6 @@ public class FusionEngine implements LocationListener { private Location mFusedLocation; private Location mGpsLocation; private Location mNetworkLocation; - private double mNetworkWeight; - private double mGpsWeight; private boolean mEnabled; private ProviderRequestUnbundled mRequest; @@ -102,10 +91,6 @@ public class FusionEngine implements LocationListener { Log.i(TAG, "engine stopped (" + mContext.getPackageName() + ")"); } - private boolean isAvailable() { - return mStats.get(GPS).available || mStats.get(NETWORK).available; - } - /** Called on mLooper thread */ public void enable() { mEnabled = true; @@ -130,7 +115,6 @@ public class FusionEngine implements LocationListener { public boolean requested; public long requestTime; public long minTime; - public long lastRequestTtff; @Override public String toString() { StringBuilder s = new StringBuilder(); @@ -171,9 +155,6 @@ public class FusionEngine implements LocationListener { return; } - ProviderStats gpsStats = mStats.get(GPS); - ProviderStats networkStats = mStats.get(NETWORK); - long networkInterval = Long.MAX_VALUE; long gpsInterval = Long.MAX_VALUE; for (LocationRequest request : mRequest.getLocationRequests()) { @@ -209,104 +190,46 @@ public class FusionEngine implements LocationListener { } } - private static double weighAccuracy(Location loc) { - double accuracy = loc.getAccuracy(); - return Math.exp(-accuracy * ACCURACY_DECAY_CONSTANT_M); - } - - private static double weighAge(Location loc) { - long ageSeconds = SystemClock.elapsedRealtimeNanos() - loc.getElapsedRealtimeNanos(); - ageSeconds /= 1000000000L; - if (ageSeconds < 0) ageSeconds = 0; - return Math.exp(-ageSeconds * AGE_DECAY_CONSTANT_S); - } - - private double weigh(double gps, double network) { - return (gps * mGpsWeight) + (network * mNetworkWeight); - } - - private double weigh(double gps, double network, double wrapMin, double wrapMax) { - // apply aliasing - double wrapWidth = wrapMax - wrapMin; - if (gps - network > wrapWidth / 2) network += wrapWidth; - else if (network - gps > wrapWidth / 2) gps += wrapWidth; - - double result = weigh(gps, network); - - // remove aliasing - if (result > wrapMax) result -= wrapWidth; - return result; + /** + * Test whether one location (a) is better to use than another (b). + */ + private static boolean isBetterThan(Location locationA, Location locationB) { + if (locationA == null) { + return false; + } + if (locationB == null) { + return true; + } + // A provider is better if the reading is sufficiently newer. Heading + // underground can cause GPS to stop reporting fixes. In this case it's + // appropriate to revert to cell, even when its accuracy is less. + if (locationA.getElapsedRealtimeNanos() > locationB.getElapsedRealtimeNanos() + SWITCH_ON_FRESHNESS_CLIFF_NS) { + return true; + } + + // A provider is better if it has better accuracy. Assuming both readings + // are fresh (and by that accurate), choose the one with the smaller + // accuracy circle. + if (!locationA.hasAccuracy()) { + return false; + } + if (!locationB.hasAccuracy()) { + return true; + } + return locationA.getAccuracy() < locationB.getAccuracy(); } private void updateFusedLocation() { - // naive fusion - mNetworkWeight = weighAccuracy(mNetworkLocation) * weighAge(mNetworkLocation); - mGpsWeight = weighAccuracy(mGpsLocation) * weighAge(mGpsLocation); - // scale mNetworkWeight and mGpsWeight so that they add to 1 - double totalWeight = mNetworkWeight + mGpsWeight; - mNetworkWeight /= totalWeight; - mGpsWeight /= totalWeight; - - Location fused = new Location(LocationManager.FUSED_PROVIDER); - // fuse lat/long - // assumes the two locations are close enough that earth curvature doesn't matter - fused.setLatitude(weigh(mGpsLocation.getLatitude(), mNetworkLocation.getLatitude())); - fused.setLongitude(weigh(mGpsLocation.getLongitude(), mNetworkLocation.getLongitude(), - -180.0, 180.0)); - - // fused accuracy - //TODO: use some real math instead of this crude fusion - // one suggestion is to fuse in a quadratic manner, eg - // sqrt(weigh(gpsAcc^2, netAcc^2)). - // another direction to explore is to consider the difference in the 2 - // locations. If the component locations overlap, the fused accuracy is - // better than the component accuracies. If they are far apart, - // the fused accuracy is much worse. - fused.setAccuracy((float)weigh(mGpsLocation.getAccuracy(), mNetworkLocation.getAccuracy())); - - // fused time - now - fused.setTime(System.currentTimeMillis()); - fused.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); - - // fuse altitude - if (mGpsLocation.hasAltitude() && !mNetworkLocation.hasAltitude() && - mGpsWeight > WEIGHT_THRESHOLD) { - fused.setAltitude(mGpsLocation.getAltitude()); // use GPS - } else if (!mGpsLocation.hasAltitude() && mNetworkLocation.hasAltitude() && - mNetworkWeight > WEIGHT_THRESHOLD) { - fused.setAltitude(mNetworkLocation.getAltitude()); // use Network - } else if (mGpsLocation.hasAltitude() && mNetworkLocation.hasAltitude()) { - fused.setAltitude(weigh(mGpsLocation.getAltitude(), mNetworkLocation.getAltitude())); - } - - // fuse speed - if (mGpsLocation.hasSpeed() && !mNetworkLocation.hasSpeed() && - mGpsWeight > WEIGHT_THRESHOLD) { - fused.setSpeed(mGpsLocation.getSpeed()); // use GPS if its not too old - } else if (!mGpsLocation.hasSpeed() && mNetworkLocation.hasSpeed() && - mNetworkWeight > WEIGHT_THRESHOLD) { - fused.setSpeed(mNetworkLocation.getSpeed()); // use Network - } else if (mGpsLocation.hasSpeed() && mNetworkLocation.hasSpeed()) { - fused.setSpeed((float)weigh(mGpsLocation.getSpeed(), mNetworkLocation.getSpeed())); - } - - // fuse bearing - if (mGpsLocation.hasBearing() && !mNetworkLocation.hasBearing() && - mGpsWeight > WEIGHT_THRESHOLD) { - fused.setBearing(mGpsLocation.getBearing()); // use GPS if its not too old - } else if (!mGpsLocation.hasBearing() && mNetworkLocation.hasBearing() && - mNetworkWeight > WEIGHT_THRESHOLD) { - fused.setBearing(mNetworkLocation.getBearing()); // use Network - } else if (mGpsLocation.hasBearing() && mNetworkLocation.hasBearing()) { - fused.setBearing((float)weigh(mGpsLocation.getBearing(), mNetworkLocation.getBearing(), - 0.0, 360.0)); + // may the best location win! + if (isBetterThan(mGpsLocation, mNetworkLocation)) { + mFusedLocation = new Location(mGpsLocation); + } else { + mFusedLocation = new Location(mNetworkLocation); } - if (mNetworkLocation != null) { - fused.setExtraLocation(Location.EXTRA_NO_GPS_LOCATION, mNetworkLocation); + mFusedLocation.setExtraLocation(Location.EXTRA_NO_GPS_LOCATION, mNetworkLocation); } - - mFusedLocation = fused; + mFusedLocation.setProvider(LocationManager.FUSED_PROVIDER); mCallback.reportLocation(mFusedLocation); } @@ -349,9 +272,9 @@ public class FusionEngine implements LocationListener { StringBuilder s = new StringBuilder(); s.append("mEnabled=" + mEnabled).append(' ').append(mRequest).append('\n'); s.append("fused=").append(mFusedLocation).append('\n'); - s.append(String.format("gps %.3f %s\n", mGpsWeight, mGpsLocation)); + s.append(String.format("gps %s\n", mGpsLocation)); s.append(" ").append(mStats.get(GPS)).append('\n'); - s.append(String.format("net %.3f %s\n", mNetworkWeight, mNetworkLocation)); + s.append(String.format("net %s\n", mNetworkLocation)); s.append(" ").append(mStats.get(NETWORK)).append('\n'); pw.append(s); } diff --git a/packages/SystemUI/res/anim/recent_app_enter.xml b/packages/SystemUI/res/anim/recent_app_enter.xml deleted file mode 100644 index 4947eeefb1a7..000000000000 --- a/packages/SystemUI/res/anim/recent_app_enter.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** Copyright 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. -*/ ---> - -<!-- Special window zoom animation: this is the element that enters the screen, - it starts at 200% and scales down. Goes with zoom_exit.xml. --> -<set xmlns:android="http://schemas.android.com/apk/res/android" - android:interpolator="@android:anim/decelerate_interpolator"> - <scale android:fromXScale="0.25" android:toXScale="1.0" - android:fromYScale="0.25" android:toYScale="1.0" - android:pivotX="0%p" android:pivotY="0%p" - android:duration="500" /> - <alpha android:fromAlpha="0.0" android:toAlpha="1.0" - android:duration="500"/> -</set> diff --git a/packages/SystemUI/res/anim/recent_app_leave.xml b/packages/SystemUI/res/anim/recent_app_leave.xml deleted file mode 100644 index 3d839881b797..000000000000 --- a/packages/SystemUI/res/anim/recent_app_leave.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** Copyright 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. -*/ ---> - -<!-- Special window zoom animation: this is the element that enters the screen, - it starts at 200% and scales down. Goes with zoom_exit.xml. --> -<set xmlns:android="http://schemas.android.com/apk/res/android" - android:interpolator="@android:anim/decelerate_interpolator"> - <scale android:fromXScale="1.0" android:toXScale="0.25" - android:fromYScale="1.0" android:toYScale="0.25" - android:pivotX="0%p" android:pivotY="0%p" - android:duration="500" /> - <alpha android:fromAlpha="1.0" android:toAlpha="0.0" - android:duration="500"/> -</set> diff --git a/packages/SystemUI/res/anim/recents_launch_from_launcher_enter.xml b/packages/SystemUI/res/anim/recents_launch_from_launcher_enter.xml new file mode 100644 index 000000000000..73ae9f2a25ee --- /dev/null +++ b/packages/SystemUI/res/anim/recents_launch_from_launcher_enter.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2012, 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. +*/ +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:detachWallpaper="true" + android:shareInterpolator="false" + android:zAdjustment="normal"> + <!--scale android:fromXScale="2.0" android:toXScale="1.0" + android:fromYScale="2.0" android:toYScale="1.0" + android:interpolator="@android:interpolator/decelerate_cubic" + android:fillEnabled="true" + android:fillBefore="true" android:fillAfter="true" + android:pivotX="50%p" android:pivotY="50%p" + android:duration="250" /--> + <alpha android:fromAlpha="0.0" android:toAlpha="1.0" + android:fillEnabled="true" + android:fillBefore="true" android:fillAfter="true" + android:interpolator="@android:interpolator/decelerate_cubic" + android:duration="250"/> +</set> diff --git a/packages/SystemUI/res/anim/recents_launch_from_launcher_exit.xml b/packages/SystemUI/res/anim/recents_launch_from_launcher_exit.xml new file mode 100644 index 000000000000..becc9d0b4fe6 --- /dev/null +++ b/packages/SystemUI/res/anim/recents_launch_from_launcher_exit.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2012, 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. +*/ +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false" + android:zAdjustment="normal"> + <alpha android:fromAlpha="1.0" android:toAlpha="0.0" + android:fillEnabled="true" + android:fillBefore="true" android:fillAfter="true" + android:interpolator="@android:interpolator/decelerate_cubic" + android:duration="250"/> +</set> diff --git a/packages/SystemUI/res/anim/recents_return_to_launcher_enter.xml b/packages/SystemUI/res/anim/recents_return_to_launcher_enter.xml new file mode 100644 index 000000000000..efa901915886 --- /dev/null +++ b/packages/SystemUI/res/anim/recents_return_to_launcher_enter.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2012, 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. +*/ +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false" + android:zAdjustment="normal"> + <alpha android:fromAlpha="0.0" android:toAlpha="1.0" + android:interpolator="@android:interpolator/decelerate_cubic" + android:duration="250"/> +</set> diff --git a/packages/SystemUI/res/anim/recents_return_to_launcher_exit.xml b/packages/SystemUI/res/anim/recents_return_to_launcher_exit.xml new file mode 100644 index 000000000000..e95e667507f3 --- /dev/null +++ b/packages/SystemUI/res/anim/recents_return_to_launcher_exit.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2012, 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. +*/ +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false" + android:zAdjustment="normal"> + <!--scale android:fromXScale="1.0" android:toXScale="2.0" + android:fromYScale="1.0" android:toYScale="2.0" + android:interpolator="@android:interpolator/decelerate_cubic" + android:pivotX="50%p" android:pivotY="50%p" + android:duration="250" /--> + <alpha android:fromAlpha="1.0" android:toAlpha="0.0" + android:interpolator="@android:interpolator/decelerate_cubic" + android:duration="250"/> +</set> diff --git a/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_normal.png b/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_normal.png Binary files differnew file mode 100644 index 000000000000..3ed741854b69 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_normal.png diff --git a/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_pressed.png b/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_pressed.png Binary files differnew file mode 100644 index 000000000000..5e20eea9b655 --- /dev/null +++ b/packages/SystemUI/res/drawable-hdpi/ic_notify_settings_pressed.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_normal.png b/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_normal.png Binary files differnew file mode 100644 index 000000000000..44cfc5bc49d3 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_normal.png diff --git a/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_pressed.png b/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_pressed.png Binary files differnew file mode 100644 index 000000000000..0c3fdcd32ae9 --- /dev/null +++ b/packages/SystemUI/res/drawable-mdpi/ic_notify_settings_pressed.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_normal.png b/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_normal.png Binary files differnew file mode 100644 index 000000000000..80fdb790891e --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_normal.png diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_pressed.png b/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_pressed.png Binary files differnew file mode 100644 index 000000000000..ac7c1a7f0e73 --- /dev/null +++ b/packages/SystemUI/res/drawable-xhdpi/ic_notify_settings_pressed.png diff --git a/packages/SystemUI/res/drawable/ic_notify_settings.xml b/packages/SystemUI/res/drawable/ic_notify_settings.xml new file mode 100644 index 000000000000..6579d8e87ac3 --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_notify_settings.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 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_pressed="true" + android:drawable="@drawable/ic_notify_settings_pressed" /> + <item + android:drawable="@drawable/ic_notify_settings_normal" /> +</selector> + diff --git a/packages/SystemUI/res/layout/status_bar_expanded_header.xml b/packages/SystemUI/res/layout/status_bar_expanded_header.xml index f1a8d8260087..c9218375182a 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded_header.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded_header.xml @@ -75,14 +75,14 @@ android:layout_width="50dp" android:layout_height="50dp" android:scaleType="center" - android:src="@drawable/ic_notify_quicksettings" + android:src="@drawable/ic_notify_settings" android:contentDescription="@string/accessibility_settings_button" /> <ImageView android:id="@+id/clear_all_button" android:layout_width="50dp" android:layout_height="50dp" - android:layout_marginLeft="18dp" + android:layout_marginLeft="12dp" android:scaleType="center" android:src="@drawable/ic_notify_clear" android:contentDescription="@string/accessibility_clear_all" diff --git a/packages/SystemUI/res/layout/super_status_bar.xml b/packages/SystemUI/res/layout/super_status_bar.xml index 4b895ec9d1ae..07aca6cfbc1c 100644 --- a/packages/SystemUI/res/layout/super_status_bar.xml +++ b/packages/SystemUI/res/layout/super_status_bar.xml @@ -42,20 +42,11 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> - <include layout="@layout/quick_settings" + <ViewStub android:id="@+id/quick_settings_stub" + android:layout="@layout/quick_settings" android:layout_width="match_parent" android:layout_height="match_parent" /> </com.android.systemui.statusbar.phone.PanelHolder> - <ViewStub - android:layout="@layout/status_bar_help" - android:id="@+id/status_bar_cling_stub" - android:inflatedId="@+id/status_bar_cling" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_marginTop="@*android:dimen/status_bar_height" - android:visibility="gone" - /> - </com.android.systemui.statusbar.phone.StatusBarWindowView> diff --git a/packages/SystemUI/res/values-sw600dp/config.xml b/packages/SystemUI/res/values-sw600dp/config.xml index 209ad11e14d5..50575d062232 100644 --- a/packages/SystemUI/res/values-sw600dp/config.xml +++ b/packages/SystemUI/res/values-sw600dp/config.xml @@ -20,6 +20,9 @@ <!-- These resources are around just to allow their values to be customized for different hardware and product builds. --> <resources> + <!-- Enable quick settings on tablets --> + <bool name="config_hasSettingsPanel">true</bool> + <!-- The number of columns in the QuickSettings --> <integer name="quick_settings_num_columns">3</integer> diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 942e814d8342..aec9555215bb 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -97,5 +97,7 @@ <integer name="blinds_pop_duration_ms">10</integer> + <!-- Disable quick settings by default --> + <bool name="config_hasSettingsPanel">false</bool> </resources> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 4bf6c109d827..4de0891349a5 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -52,7 +52,7 @@ <dimen name="status_bar_recents_item_padding">0dip</dimen> <!-- When recents first appears, how far the icon and label of the primary activity travel --> - <dimen name="status_bar_recents_app_icon_translate_distance">100dp</dimen> + <dimen name="status_bar_recents_app_icon_translate_distance">35dip</dimen> <!-- Where to place the app icon over the thumbnail --> <dimen name="status_bar_recents_app_icon_left_margin">0dp</dimen> diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml index 4a732008137a..2cc344630db0 100644 --- a/packages/SystemUI/res/values/ids.xml +++ b/packages/SystemUI/res/values/ids.xml @@ -19,4 +19,5 @@ <item type="id" name="expandable_tag" /> <item type="id" name="user_expanded_tag" /> <item type="id" name="user_lock_tag" /> + <item type="id" name="status_bar_cling_stub" /> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java index f71f55476052..bc61ab0addc4 100644 --- a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java @@ -184,8 +184,8 @@ public class SearchPanelView extends FrameLayout implements private void vibrate() { Context context = getContext(); - if (Settings.System.getInt(context.getContentResolver(), - Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) != 0) { + if (Settings.System.getIntForUser(context.getContentResolver(), + Settings.System.HAPTIC_FEEDBACK_ENABLED, 1, UserHandle.USER_CURRENT) != 0) { Resources res = context.getResources(); Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(res.getInteger(R.integer.config_search_panel_view_vibration_duration)); diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java index 79069b89c42a..ef9f36e45951 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java @@ -18,6 +18,7 @@ package com.android.systemui.recent; import android.app.Activity; import android.app.ActivityManager; +import android.app.WallpaperManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -26,6 +27,7 @@ import android.os.Bundle; import android.os.UserHandle; import android.view.MotionEvent; import android.view.View; +import android.view.WindowManager; import com.android.systemui.R; import com.android.systemui.SystemUIApplication; @@ -42,6 +44,7 @@ public class RecentsActivity extends Activity { private IntentFilter mIntentFilter; private boolean mShowing; private boolean mForeground; + private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -79,6 +82,9 @@ public class RecentsActivity extends Activity { @Override public void onPause() { + overridePendingTransition( + R.anim.recents_return_to_launcher_enter, + R.anim.recents_return_to_launcher_exit); mForeground = false; super.onPause(); } @@ -92,8 +98,23 @@ public class RecentsActivity extends Activity { super.onStop(); } + private void updateWallpaperVisibility(boolean visible) { + int wpflags = visible ? WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER : 0; + int curflags = getWindow().getAttributes().flags + & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; + if (wpflags != curflags) { + getWindow().setFlags(wpflags, WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER); + } + } + @Override public void onStart() { + // Hide wallpaper if it's not a static image + if (WallpaperManager.getInstance(this).getWallpaperInfo() != null) { + updateWallpaperVisibility(false); + } else { + updateWallpaperVisibility(true); + } mShowing = true; if (mRecentsPanel != null) { mRecentsPanel.refreshViews(); diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index 8607508b9bce..57d2ed35505a 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -520,7 +520,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener public void onWindowAnimationStart() { if (mItemToAnimateInWhenWindowAnimationIsFinished != null) { - final int startDelay = 100; + final int startDelay = 150; final int duration = 250; final ViewHolder holder = mItemToAnimateInWhenWindowAnimationIsFinished; final TimeInterpolator cubic = new DecelerateInterpolator(1.5f); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 3e929d68a13d..577b1f4f1e2c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -485,7 +485,11 @@ public abstract class BaseStatusBar extends SystemUI implements | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); if (firstTask == null) { - mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT)); + ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, + R.anim.recents_launch_from_launcher_enter, + R.anim.recents_launch_from_launcher_exit); + mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle( + UserHandle.USER_CURRENT)); } else { Bitmap first = firstTask.getThumbnail(); final Resources res = mContext.getResources(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java index 3fd413ad51dd..d0fc340f1391 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java @@ -57,9 +57,9 @@ public class PanelBar extends FrameLayout { mPanelHolder = ph; final int N = ph.getChildCount(); for (int i=0; i<N; i++) { - final PanelView v = (PanelView) ph.getChildAt(i); - if (v != null) { - addPanel(v); + final View v = ph.getChildAt(i); + if (v != null && v instanceof PanelView) { + addPanel((PanelView) v); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index d68151d86419..75a259840ebf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -188,12 +188,13 @@ public class PhoneStatusBar extends BaseStatusBar { TextView mNotificationPanelDebugText; // settings + boolean mHasSettingsPanel; SettingsPanelView mSettingsPanel; int mSettingsPanelGravity; // top bar View mClearButton; - View mSettingsButton; + ImageView mSettingsButton; // carrier/wifi label private TextView mCarrierLabel; @@ -420,13 +421,25 @@ public class PhoneStatusBar extends BaseStatusBar { mClearButton.setVisibility(View.INVISIBLE); mClearButton.setEnabled(false); mDateView = (DateView)mStatusBarWindow.findViewById(R.id.date); - mSettingsButton = mStatusBarWindow.findViewById(R.id.settings_button); + + mHasSettingsPanel = res.getBoolean(R.bool.config_hasSettingsPanel); + + mSettingsButton = (ImageView) mStatusBarWindow.findViewById(R.id.settings_button); if (mSettingsButton != null) { - if (mStatusBarView.hasFullWidthNotifications()) { - mSettingsButton.setOnClickListener(mSettingsButtonListener); - mSettingsButton.setVisibility(View.VISIBLE); + mSettingsButton.setOnClickListener(mSettingsButtonListener); + if (mHasSettingsPanel) { + if (mStatusBarView.hasFullWidthNotifications()) { + // the settings panel is hiding behind this button + mSettingsButton.setImageResource(R.drawable.ic_notify_quicksettings); + mSettingsButton.setVisibility(View.VISIBLE); + } else { + // there is a settings panel, but it's on the other side of the (large) screen + mSettingsButton.setVisibility(View.GONE); + } } else { - mSettingsButton.setVisibility(View.GONE); + // no settings panel, go straight to settings + mSettingsButton.setVisibility(View.VISIBLE); + mSettingsButton.setImageResource(R.drawable.ic_notify_settings); } } @@ -490,18 +503,31 @@ public class PhoneStatusBar extends BaseStatusBar { }); } - // Quick Settings (WIP) - mSettingsPanel = (SettingsPanelView) mStatusBarWindow.findViewById(R.id.settings_panel); - mSettingsPanel.setBar(mStatusBarView); - mSettingsPanel.setService(this); - mSettingsPanel.setup(mNetworkController, mBluetoothController, mBatteryController, - mLocationController); - mSettingsPanel.setSystemUiVisibility( - View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER | View.STATUS_BAR_DISABLE_SYSTEM_INFO); + // Quick Settings (where available, some restrictions apply) + if (mHasSettingsPanel) { + final View settings_stub + = mStatusBarWindow.findViewById(R.id.quick_settings_stub); - if (!ActivityManager.isHighEndGfx()) { - mSettingsPanel.setBackground(new FastColorDrawable(context.getResources().getColor( - R.color.notification_panel_solid_background))); + if (settings_stub != null) { + mSettingsPanel = (SettingsPanelView) ((ViewStub)settings_stub).inflate(); + } else { + mSettingsPanel = (SettingsPanelView) mStatusBarWindow.findViewById(R.id.settings_panel); + } + + if (mSettingsPanel != null) { + mSettingsPanel.setBar(mStatusBarView); + mSettingsPanel.setService(this); + mSettingsPanel.setup(mNetworkController, mBluetoothController, mBatteryController, + mLocationController); + mSettingsPanel.setSystemUiVisibility( + View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER + | View.STATUS_BAR_DISABLE_SYSTEM_INFO); + + if (!ActivityManager.isHighEndGfx()) { + mSettingsPanel.setBackground(new FastColorDrawable(context.getResources().getColor( + R.color.notification_panel_solid_background))); + } + } } mClingShown = ! (DEBUG_CLINGS @@ -1286,7 +1312,7 @@ public class PhoneStatusBar extends BaseStatusBar { return; } - mSettingsPanel.expand(); + if (mSettingsPanel != null) mSettingsPanel.expand(); if (false) postStartTracing(); } @@ -1596,7 +1622,7 @@ public class PhoneStatusBar extends BaseStatusBar { mCommandQueue.setNavigationIconHints( altBack ? (mNavigationIconHints | StatusBarManager.NAVIGATION_HINT_BACK_ALT) : (mNavigationIconHints & ~StatusBarManager.NAVIGATION_HINT_BACK_ALT)); - mSettingsPanel.setImeWindowStatus(vis > 0); + if (mSettingsPanel != null) mSettingsPanel.setImeWindowStatus(vis > 0); } @Override @@ -1820,10 +1846,12 @@ public class PhoneStatusBar extends BaseStatusBar { lp.leftMargin = mNotificationPanelMarginPx; mNotificationPanel.setLayoutParams(lp); - lp = (FrameLayout.LayoutParams) mSettingsPanel.getLayoutParams(); - lp.gravity = mSettingsPanelGravity; - lp.rightMargin = mNotificationPanelMarginPx; - mSettingsPanel.setLayoutParams(lp); + if (mSettingsPanel != null) { + lp = (FrameLayout.LayoutParams) mSettingsPanel.getLayoutParams(); + lp.gravity = mSettingsPanelGravity; + lp.rightMargin = mNotificationPanelMarginPx; + mSettingsPanel.setLayoutParams(lp); + } updateCarrierLabelVisibility(false); } @@ -1916,7 +1944,19 @@ public class PhoneStatusBar extends BaseStatusBar { private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() { public void onClick(View v) { - animateExpandSettingsPanel(); + if (mHasSettingsPanel) { + animateExpandSettingsPanel(); + } else { + try { + // Dismiss the lock screen when Settings starts. + ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); + } catch (RemoteException e) { + } + Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT)); + animateCollapsePanels(); + } } }; @@ -2010,7 +2050,7 @@ public class PhoneStatusBar extends BaseStatusBar { } // Update the QuickSettings container - mSettingsPanel.updateResources(); + if (mSettingsPanel != null) mSettingsPanel.updateResources(); loadDimens(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index 96f729ea173d..3c2f0e67d266 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -109,7 +109,8 @@ public class PhoneStatusBarView extends PanelBar { if (mFullWidthNotifications) { // No double swiping. If either panel is open, nothing else can be pulled down. - return (mSettingsPanel.getExpandedHeight() + mNotificationPanel.getExpandedHeight()> 0) + return ((mSettingsPanel == null ? 0 : mSettingsPanel.getExpandedHeight()) + + mNotificationPanel.getExpandedHeight() > 0) ? null : mNotificationPanel; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java index 8c390c89bf2d..faf20e2b7fc4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java @@ -754,6 +754,7 @@ class QuickSettings { mBrightnessDialog.setCanceledOnTouchOutside(true); mBrightnessController = new BrightnessController(mContext, + (ImageView) mBrightnessDialog.findViewById(R.id.brightness_icon), (ToggleSlider) mBrightnessDialog.findViewById(R.id.brightness_slider)); mBrightnessController.addStateChangedCallback(mModel); mBrightnessDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java index 00095037145b..e18b28ad68c1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java @@ -28,6 +28,7 @@ import android.provider.Settings.SettingNotFoundException; import android.util.Slog; import android.view.IWindowManager; import android.widget.CompoundButton; +import android.widget.ImageView; import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; @@ -40,6 +41,7 @@ public class BrightnessController implements ToggleSlider.Listener { private final int mMaximumBacklight; private final Context mContext; + private final ImageView mIcon; private final ToggleSlider mControl; private final boolean mAutomaticAvailable; private final IPowerManager mPower; @@ -52,8 +54,9 @@ public class BrightnessController implements ToggleSlider.Listener { public void onBrightnessLevelChanged(); } - public BrightnessController(Context context, ToggleSlider control) { + public BrightnessController(Context context, ImageView icon, ToggleSlider control) { mContext = context; + mIcon = icon; mControl = control; mUserTracker = new CurrentUserTracker(mContext); @@ -84,8 +87,10 @@ public class BrightnessController implements ToggleSlider.Listener { automatic = 0; } control.setChecked(automatic != 0); + updateIcon(automatic != 0); } else { control.setChecked(false); + updateIcon(false /*automatic*/); //control.hideToggle(); } @@ -105,6 +110,7 @@ public class BrightnessController implements ToggleSlider.Listener { public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) { setMode(automatic ? Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC : Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); + updateIcon(automatic); if (!automatic) { final int val = value + mMinimumBacklight; setBrightness(val); @@ -136,4 +142,12 @@ public class BrightnessController implements ToggleSlider.Listener { } catch (RemoteException ex) { } } + + private void updateIcon(boolean automatic) { + if (mIcon != null) { + mIcon.setImageResource(automatic ? + com.android.systemui.R.drawable.ic_qs_brightness_auto_on : + com.android.systemui.R.drawable.ic_qs_brightness_auto_off); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java index 194f1f69f84a..f71842eae913 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java @@ -78,6 +78,7 @@ public class SettingsView extends LinearLayout implements View.OnClickListener { }); mBrightness = new BrightnessController(context, + (ImageView)findViewById(R.id.brightness_icon), (ToggleSlider)findViewById(R.id.brightness)); mDoNotDisturb = new DoNotDisturbController(context, (CompoundButton)findViewById(R.id.do_not_disturb_checkbox)); diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index 498702004cb0..fc1cac680e1c 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -195,7 +195,8 @@ public class KeyguardHostView extends KeyguardViewBase { protected void onAttachedToWindow() { super.onAttachedToWindow(); mAppWidgetHost.startListening(); - maybePopulateWidgets(); + // TODO: Re-enable when we have layouts that can support a better variety of widgets. + // maybePopulateWidgets(); disableStatusViewInteraction(); post(mSwitchPageRunnable); } @@ -643,11 +644,7 @@ public class KeyguardHostView extends KeyguardViewBase { if (securityMode == SecurityMode.None) { // Discard current runnable if we're switching back to the selector view setOnDismissRunnable(null); - setSystemUiVisibility(getSystemUiVisibility() | View.STATUS_BAR_DISABLE_BACK); - } else { - setSystemUiVisibility(getSystemUiVisibility() & (~View.STATUS_BAR_DISABLE_BACK)); - } - + } mCurrentSecuritySelection = securityMode; } @@ -787,17 +784,12 @@ public class KeyguardHostView extends KeyguardViewBase { public void onListenerDetached() { int page = getWidgetPosition(R.id.keyguard_transport_control); if (page != -1) { - if (page == mAppWidgetContainer.getCurrentPage()) { - // Switch back to clock view if music was showing. - mAppWidgetContainer - .setCurrentPage(getWidgetPosition(R.id.keyguard_status_view)); - } mAppWidgetContainer.removeView(mTransportControl); - // XXX keep view attached to hierarchy so we still get show/hide events - // from AudioManager + // XXX keep view attached so we still get show/hide events from AudioManager KeyguardHostView.this.addView(mTransportControl); mTransportControl.setVisibility(View.GONE); mTransportState = TRANSPORT_GONE; + mTransportControl.post(mSwitchPageRunnable); } } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java index a472c8a0a209..8df6f8e6c10d 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java @@ -207,12 +207,13 @@ public class KeyguardPasswordView extends LinearLayout }); } - // If no icon is visible, reset the left margin on the password field so the text is + // If no icon is visible, reset the start margin on the password field so the text is // still centered. if (!imeOrDeleteButtonVisible) { android.view.ViewGroup.LayoutParams params = mPasswordEntry.getLayoutParams(); if (params instanceof MarginLayoutParams) { - ((MarginLayoutParams)params).leftMargin = 0; + final MarginLayoutParams mlp = (MarginLayoutParams) params; + mlp.setMarginStart(0); mPasswordEntry.setLayoutParams(params); } } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java index 1ec4176596f9..0ad2404c7d4a 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java @@ -210,6 +210,18 @@ public class KeyguardViewManager { mKeyguardView.setLockPatternUtils(mLockPatternUtils); mKeyguardView.setViewMediatorCallback(mViewMediatorCallback); + // HACK + // The keyguard view will have set up window flags in onFinishInflate before we set + // the view mediator callback. Make sure it knows the correct IME state. + if (mViewMediatorCallback != null) { + KeyguardPasswordView kpv = (KeyguardPasswordView) mKeyguardView.findViewById( + R.id.keyguard_password_view); + + if (kpv != null) { + mViewMediatorCallback.setNeedsInput(kpv.needsInput()); + } + } + if (options != null) { if (options.getBoolean(LockPatternUtils.KEYGUARD_SHOW_USER_SWITCHER)) { mKeyguardView.goToUserSwitcher(); diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index daed0a204d0c..7132e1e66eb7 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -3930,48 +3930,54 @@ public final class ActivityManagerService extends ActivityManagerNative removeDyingProviderLocked(null, providers.get(i), true); } - if (mIntentSenderRecords.size() > 0) { - Iterator<WeakReference<PendingIntentRecord>> it - = mIntentSenderRecords.values().iterator(); - while (it.hasNext()) { - WeakReference<PendingIntentRecord> wpir = it.next(); - if (wpir == null) { - it.remove(); - continue; - } - PendingIntentRecord pir = wpir.get(); - if (pir == null) { - it.remove(); - continue; - } - if (name == null) { - // Stopping user, remove all objects for the user. - if (pir.key.userId != userId) { - // Not the same user, skip it. + if (name == null) { + // Remove pending intents. For now we only do this when force + // stopping users, because we have some problems when doing this + // for packages -- app widgets are not currently cleaned up for + // such packages, so they can be left with bad pending intents. + if (mIntentSenderRecords.size() > 0) { + Iterator<WeakReference<PendingIntentRecord>> it + = mIntentSenderRecords.values().iterator(); + while (it.hasNext()) { + WeakReference<PendingIntentRecord> wpir = it.next(); + if (wpir == null) { + it.remove(); continue; } - } else { - if (UserHandle.getAppId(pir.uid) != appId) { - // Different app id, skip it. + PendingIntentRecord pir = wpir.get(); + if (pir == null) { + it.remove(); continue; } - if (userId != UserHandle.USER_ALL && pir.key.userId != userId) { - // Different user, skip it. - continue; + if (name == null) { + // Stopping user, remove all objects for the user. + if (pir.key.userId != userId) { + // Not the same user, skip it. + continue; + } + } else { + if (UserHandle.getAppId(pir.uid) != appId) { + // Different app id, skip it. + continue; + } + if (userId != UserHandle.USER_ALL && pir.key.userId != userId) { + // Different user, skip it. + continue; + } + if (!pir.key.packageName.equals(name)) { + // Different package, skip it. + continue; + } } - if (!pir.key.packageName.equals(name)) { - // Different package, skip it. - continue; + if (!doit) { + return true; + } + didSomething = true; + it.remove(); + pir.canceled = true; + if (pir.key.activity != null) { + pir.key.activity.pendingResults.remove(pir.ref); } - } - if (!doit) { - return true; - } - didSomething = true; - it.remove(); - pir.canceled = true; - if (pir.key.activity != null) { - pir.key.activity.pendingResults.remove(pir.ref); } } } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java index 292082424543..2303fc3dd564 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java @@ -52,8 +52,10 @@ public class Blend extends TestBase { new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { currentIntrinsic = pos; - runTest(); - act.updateDisplay(); + if (mRS != null) { + runTest(); + act.updateDisplay(); + } } public void onNothingSelected(AdapterView parent) { diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java index 8009daae900d..bb3f2f3d571e 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java @@ -123,6 +123,7 @@ public class TestBase { public void destroy() { mRS.destroy(); + mRS = null; } public void updateBitmap(Bitmap b) { diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs index a83e81986116..ba8711ba0db7 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colormatrix.fs @@ -29,10 +29,10 @@ void setMatrix(rs_matrix4x4 m) { Mat = m; } -void root(const uchar4 *in, uchar4 *out) { - float4 f = convert_float4(*in); +uchar4 __attribute__((kernel)) root(uchar4 in) { + float4 f = convert_float4(in); f = rsMatrixMultiply(&Mat, f); f = clamp(f, 0.f, 255.f); - *out = convert_uchar4(f); + return convert_uchar4(f); } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs index 981282795b57..772503f3649b 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve3x3.fs @@ -24,7 +24,7 @@ rs_allocation gIn; float gCoeffs[9]; -void root(uchar4 *out, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) { uint32_t x1 = min((int32_t)x+1, gWidth-1); uint32_t x2 = max((int32_t)x-1, 0); uint32_t y1 = min((int32_t)y+1, gHeight-1); @@ -61,7 +61,7 @@ void root(uchar4 *out, uint32_t x, uint32_t y) { p20 += p02; p20 = clamp(p20, 0.f, 255.f); - *out = convert_uchar4(p20); + return convert_uchar4(p20); } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.fs index e6d03c9c0554..a916bfb28864 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/convolve5x5.fs @@ -24,7 +24,7 @@ rs_allocation gIn; float gCoeffs[25]; -void root(uchar4 *out, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) { uint32_t x0 = max((int32_t)x-2, 0); uint32_t x1 = max((int32_t)x-1, 0); uint32_t x2 = x; @@ -68,7 +68,7 @@ void root(uchar4 *out, uint32_t x, uint32_t y) { + convert_float4(rsGetElementAt_uchar4(gIn, x4, y4)) * gCoeffs[24]; p0 = clamp(p0 + p1 + p2 + p3 + p4, 0.f, 255.f); - *out = convert_uchar4(p0); + return convert_uchar4(p0); } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.fs index 9eb5d43b28e4..5f03483f445a 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.fs @@ -17,8 +17,8 @@ #pragma version(1) #pragma rs java_package_name(com.android.rs.image) -void root(const uchar4 *v_in, uchar4 *v_out) { - *v_out = *v_in; +uchar4 __attribute__((kernel)) root(uchar4 v_in) { + return v_in; } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh index 3809912eac89..2eacb7d456b6 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye.rsh @@ -26,7 +26,7 @@ void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, neg_center = -center; inv_dimensions.x = 1.f / (float)dim_x; inv_dimensions.y = 1.f / (float)dim_y; - alpha = k * 2.0 + 0.75; + alpha = k * 2.0f + 0.75f; axis_scale = (float2)1.f; if (dim_x > dim_y) @@ -34,15 +34,15 @@ void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, else axis_scale.x = (float)dim_x / (float)dim_y; - const float bound2 = 0.25 * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y); + const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y); const float bound = sqrt(bound2); - const float radius = 1.15 * bound; + const float radius = 1.15f * bound; radius2 = radius*radius; const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2)); factor = bound / max_radian; } -void root(uchar4 *out, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) { // Convert x and y to floating point coordinates with center as origin const float2 inCoord = {(float)x, (float)y}; const float2 coord = mad(inCoord, inv_dimensions, neg_center); @@ -53,6 +53,6 @@ void root(uchar4 *out, uint32_t x, uint32_t y) { const float scalar = radian * factor * inv_dist; const float2 new_coord = mad(coord, scalar, center); const float4 fout = rsSample(in_alloc, sampler, new_coord); - *out = rsPackColorTo8888(fout); + return rsPackColorTo8888(fout); } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh index 08b412624de0..fcf0a3dca4ee 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx.rsh @@ -26,7 +26,7 @@ void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, neg_center = -center; inv_dimensions.x = 1.f / (float)dim_x; inv_dimensions.y = 1.f / (float)dim_y; - alpha = k * 2.0 + 0.75; + alpha = k * 2.0f + 0.75f; axis_scale = (float2)1.f; if (dim_x > dim_y) @@ -34,15 +34,15 @@ void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, else axis_scale.x = (float)dim_x / (float)dim_y; - const float bound2 = 0.25 * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y); + const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y); const float bound = sqrt(bound2); - const float radius = 1.15 * bound; + const float radius = 1.15f * bound; radius2 = radius*radius; const float max_radian = M_PI_2 - atan(alpha / bound * sqrt(radius2 - bound2)); factor = bound / max_radian; } -void root(uchar4 *out, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) { // Convert x and y to floating point coordinates with center as origin const float2 inCoord = {(float)x, (float)y}; const float2 coord = mad(inCoord, inv_dimensions, neg_center); @@ -53,6 +53,6 @@ void root(uchar4 *out, uint32_t x, uint32_t y) { const float scalar = radian * factor * inv_dist; const float2 new_coord = mad(coord, scalar, center); const float4 fout = rsSample(in_alloc, sampler, new_coord); - *out = rsPackColorTo8888(fout); + return rsPackColorTo8888(fout); } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.fs index 3e76368319fb..3e76368319fb 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_approx_relaxed.fs diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.fs index dc3ffcb83419..dc3ffcb83419 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/fisheye_relaxed.fs diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.fs index c8531f39c1bb..4ae095dcafac 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.fs @@ -18,8 +18,8 @@ #pragma rs java_package_name(com.android.rs.image) #pragma rs_fp_relaxed -void genRand(uchar *out) { - *out = (uchar)rsRand(0xff); +uchar __attribute__((kernel)) genRand() { + return (uchar)rsRand(0xff); } /* @@ -42,7 +42,7 @@ int32_t gWMask; int32_t gHMask; rs_allocation gBlendSource; -void blend9(uchar *out, uint32_t x, uint32_t y) { +uchar __attribute__((kernel)) blend9(uint32_t x, uint32_t y) { uint32_t x1 = (x-1) & gWMask; uint32_t x2 = (x+1) & gWMask; uint32_t y1 = (y-1) & gHMask; @@ -70,14 +70,14 @@ void blend9(uchar *out, uint32_t x, uint32_t y) { p20 += p02; p20 = min(p20 >> 10, (uint)255); - *out = (uchar)p20; + return (uchar)p20; } float gNoiseStrength; rs_allocation gNoise; -void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { - float4 ip = convert_float4(*in); +uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) { + float4 ip = convert_float4(in); float pnoise = (float) rsGetElementAt_uchar(gNoise, x & gWMask, y & gHMask); float energy_level = ip.r + ip.g + ip.b; @@ -89,5 +89,5 @@ void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { uchar4 p = convert_uchar4(ip); p.a = 0xff; - *out = p; + return p; } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs index c420cac5d910..90ba058ae4e2 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/greyscale.fs @@ -20,11 +20,11 @@ const static float3 gMonoMult = {0.299f, 0.587f, 0.114f}; -void root(const uchar4 *v_in, uchar4 *v_out) { - float4 f4 = rsUnpackColor8888(*v_in); +uchar4 __attribute__((kernel)) root(uchar4 v_in) { + float4 f4 = rsUnpackColor8888(v_in); float3 mono = dot(f4.rgb, gMonoMult); - *v_out = rsPackColorTo8888(mono); + return rsPackColorTo8888(mono); } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh index 7c5d930f111c..e289906b1cdd 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels.rsh @@ -21,24 +21,26 @@ float outWMinOutB; float overInWMinInB; rs_matrix3x3 colorMat; -void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { - float3 pixel = convert_float4(in[0]).rgb; +uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) { + uchar4 out; + float3 pixel = convert_float4(in).rgb; pixel = rsMatrixMultiply(&colorMat, pixel); pixel = clamp(pixel, 0.f, 255.f); pixel = (pixel - inBlack) * overInWMinInB; pixel = pixel * outWMinOutB + outBlack; pixel = clamp(pixel, 0.f, 255.f); - out->xyz = convert_uchar3(pixel); - out->w = 0xff; + out.xyz = convert_uchar3(pixel); + out.w = 0xff; + return out; } -void root4(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { - float4 pixel = convert_float4(in[0]); +uchar4 __attribute__((kernel)) root4(uchar4 in, uint32_t x, uint32_t y) { + float4 pixel = convert_float4(in); pixel.rgb = rsMatrixMultiply(&colorMat, pixel.rgb); pixel = clamp(pixel, 0.f, 255.f); pixel = (pixel - inBlack) * overInWMinInB; pixel = pixel * outWMinOutB + outBlack; pixel = clamp(pixel, 0.f, 255.f); - out->xyzw = convert_uchar4(pixel); + return convert_uchar4(pixel); } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.fs index b1154455a26e..b1154455a26e 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/levels_relaxed.fs diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.fs index da81d2e82a4e..ac2061b23f1b 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.fs @@ -23,7 +23,7 @@ float lowerBoundX = -2.f; float lowerBoundY = -2.f; float scaleFactor = 4.f; -void root(uchar4 *v_out, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) { float2 p; p.x = lowerBoundX + ((float)x / gDimX) * scaleFactor; p.y = lowerBoundY + ((float)y / gDimY) * scaleFactor; @@ -41,16 +41,16 @@ void root(uchar4 *v_out, uint32_t x, uint32_t y) { if(iter >= gMaxIteration) { // write a non-transparent black pixel - *v_out = (uchar4){0, 0, 0, 0xff}; + return (uchar4){0, 0, 0, 0xff}; } else { - float mi3 = gMaxIteration / 3.; + float mi3 = gMaxIteration / 3.f; if (iter <= (gMaxIteration / 3)) - *v_out = (uchar4){0xff * (iter / mi3), 0, 0, 0xff}; + return (uchar4){0xff * (iter / mi3), 0, 0, 0xff}; else if (iter <= (((gMaxIteration / 3) * 2))) - *v_out = (uchar4){0xff - (0xff * ((iter - mi3) / mi3)), - (0xff * ((iter - mi3) / mi3)), 0, 0xff}; + return (uchar4){0xff - (0xff * ((iter - mi3) / mi3)), + (0xff * ((iter - mi3) / mi3)), 0, 0xff}; else - *v_out = (uchar4){0, 0xff - (0xff * ((iter - (mi3 * 2)) / mi3)), - (0xff * ((iter - (mi3 * 2)) / mi3)), 0xff}; + return (uchar4){0, 0xff - (0xff * ((iter - (mi3 * 2)) / mi3)), + (0xff * ((iter - (mi3 * 2)) / mi3)), 0xff}; } } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs index 3dfa94b84908..86e155a627dd 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/threshold.fs @@ -56,51 +56,49 @@ void setRadius(int rad) { } } -void copyIn(const uchar4 *in, float4 *out) { - *out = convert_float4(*in); +float4 __attribute__((kernel)) copyIn(uchar4 in) { + return convert_float4(in); } -void vert(uchar4 *out, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) vert(uint32_t x, uint32_t y) { float3 blurredPixel = 0; - const float *gPtr = gaussian; + int gi = 0; + uchar4 out; if ((y > radius) && (y < (height - radius))) { for (int r = -radius; r <= radius; r ++) { - const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel2, x, y + r); - blurredPixel += i->xyz * gPtr[0]; - gPtr++; + float4 i = rsGetElementAt_float4(ScratchPixel2, x, y + r); + blurredPixel += i.xyz * gaussian[gi++]; } } else { for (int r = -radius; r <= radius; r ++) { int validH = rsClamp((int)y + r, (int)0, (int)(height - 1)); - const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel2, x, validH); - blurredPixel += i->xyz * gPtr[0]; - gPtr++; + float4 i = rsGetElementAt_float4(ScratchPixel2, x, validH); + blurredPixel += i.xyz * gaussian[gi++]; } } - out->xyz = convert_uchar3(clamp(blurredPixel, 0.f, 255.f)); - out->w = 0xff; + out.xyz = convert_uchar3(clamp(blurredPixel, 0.f, 255.f)); + out.w = 0xff; + return out; } -void horz(float4 *out, uint32_t x, uint32_t y) { - float3 blurredPixel = 0; - const float *gPtr = gaussian; +float4 __attribute__((kernel)) horz(uint32_t x, uint32_t y) { + float4 blurredPixel = 0; + int gi = 0; if ((x > radius) && (x < (width - radius))) { for (int r = -radius; r <= radius; r ++) { - const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel1, x + r, y); - blurredPixel += i->xyz * gPtr[0]; - gPtr++; + float4 i = rsGetElementAt_float4(ScratchPixel1, x + r, y); + blurredPixel += i * gaussian[gi++]; } } else { for (int r = -radius; r <= radius; r ++) { // Stepping left and right away from the pixel int validX = rsClamp((int)x + r, (int)0, (int)(width - 1)); - const float4 *i = (const float4 *)rsGetElementAt(ScratchPixel1, validX, y); - blurredPixel += i->xyz * gPtr[0]; - gPtr++; + float4 i = rsGetElementAt_float4(ScratchPixel1, validX, y); + blurredPixel += i * gaussian[gi++]; } } - out->xyz = blurredPixel; + return blurredPixel; } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh index a1e4ae545f93..04ca1f192070 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh @@ -31,29 +31,29 @@ void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_ else axis_scale.x = (float)dim_x / (float)dim_y; - const float max_dist = 0.5 * length(axis_scale); + const float max_dist = 0.5f * length(axis_scale); sloped_inv_max_dist = desired_slope * 1.f/max_dist; // Range needs to be between 1.3 to 0.6. When scale is zero then range is // 1.3 which means no vignette at all because the luminousity difference is // less than 1/256. Expect input scale to be between 0.0 and 1.0. - const float neg_range = 0.7*sqrt(desired_scale) - 1.3; + const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f; sloped_neg_range = exp(neg_range * desired_slope); shade = desired_shade; opp_shade = 1.f - desired_shade; } -void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) { // Convert x and y to floating point coordinates with center as origin - const float4 fin = convert_float4(*in); + const float4 fin = convert_float4(in); const float2 inCoord = {(float)x, (float)y}; const float2 coord = mad(inCoord, inv_dimensions, neg_center); const float sloped_dist_ratio = length(axis_scale * coord) * sloped_inv_max_dist; - const float lumen = opp_shade + shade / ( 1.0 + sloped_neg_range * exp(sloped_dist_ratio) ); + const float lumen = opp_shade + shade / ( 1.0f + sloped_neg_range * exp(sloped_dist_ratio) ); float4 fout; fout.rgb = fin.rgb * lumen; fout.w = fin.w; - *out = convert_uchar4(fout); + return convert_uchar4(fout); } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh index 7f7bdcf6570f..05a5929b5d70 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx.rsh @@ -31,22 +31,22 @@ void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_ else axis_scale.x = (float)dim_x / (float)dim_y; - const float max_dist = 0.5 * length(axis_scale); + const float max_dist = 0.5f * length(axis_scale); sloped_inv_max_dist = desired_slope * 1.f/max_dist; // Range needs to be between 1.3 to 0.6. When scale is zero then range is // 1.3 which means no vignette at all because the luminousity difference is // less than 1/256. Expect input scale to be between 0.0 and 1.0. - const float neg_range = 0.7*sqrt(desired_scale) - 1.3; + const float neg_range = 0.7f*sqrt(desired_scale) - 1.3f; sloped_neg_range = exp(neg_range * desired_slope); shade = desired_shade; opp_shade = 1.f - desired_shade; } -void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) { // Convert x and y to floating point coordinates with center as origin - const float4 fin = convert_float4(*in); + const float4 fin = convert_float4(in); const float2 inCoord = {(float)x, (float)y}; const float2 coord = mad(inCoord, inv_dimensions, neg_center); const float sloped_dist_ratio = fast_length(axis_scale * coord) * sloped_inv_max_dist; @@ -55,6 +55,6 @@ void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { float4 fout; fout.rgb = fin.rgb * lumen; fout.w = fin.w; - *out = convert_uchar4(fout); + return convert_uchar4(fout); } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.fs index 912061282e52..912061282e52 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_approx_relaxed.fs diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.fs index 8e47ea96989e..8e47ea96989e 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette_relaxed.fs |