diff options
91 files changed, 1025 insertions, 894 deletions
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index 28559cc5029a..ad8d41fafb4f 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -226,6 +226,14 @@ public class DownloadManager { public final static int ERROR_FILE_ALREADY_EXISTS = 1009; /** + * Value of {@link #COLUMN_REASON} when the download has failed because of + * {@link NetworkPolicyManager} controls on the requesting application. + * + * @hide + */ + public final static int ERROR_BLOCKED = 1010; + + /** * Value of {@link #COLUMN_REASON} when the download is paused because some network error * occurred and the download manager is waiting before retrying the request. */ @@ -249,14 +257,6 @@ public class DownloadManager { public final static int PAUSED_UNKNOWN = 4; /** - * Value of {@link #COLUMN_REASON} when the download has been paused because - * of {@link NetworkPolicyManager} controls on the requesting application. - * - * @hide - */ - public final static int PAUSED_BY_POLICY = 5; - - /** * Broadcast intent action sent by the download manager when a download completes. */ public final static String ACTION_DOWNLOAD_COMPLETE = "android.intent.action.DOWNLOAD_COMPLETE"; @@ -804,7 +804,6 @@ public class DownloadManager { parts.add(statusClause("=", Downloads.Impl.STATUS_WAITING_TO_RETRY)); parts.add(statusClause("=", Downloads.Impl.STATUS_WAITING_FOR_NETWORK)); parts.add(statusClause("=", Downloads.Impl.STATUS_QUEUED_FOR_WIFI)); - parts.add(statusClause("=", Downloads.Impl.STATUS_PAUSED_BY_POLICY)); } if ((mStatusFlags & STATUS_SUCCESSFUL) != 0) { parts.add(statusClause("=", Downloads.Impl.STATUS_SUCCESS)); @@ -1275,9 +1274,6 @@ public class DownloadManager { case Downloads.Impl.STATUS_QUEUED_FOR_WIFI: return PAUSED_QUEUED_FOR_WIFI; - case Downloads.Impl.STATUS_PAUSED_BY_POLICY: - return PAUSED_BY_POLICY; - default: return PAUSED_UNKNOWN; } @@ -1316,6 +1312,9 @@ public class DownloadManager { case Downloads.Impl.STATUS_FILE_ALREADY_EXISTS_ERROR: return ERROR_FILE_ALREADY_EXISTS; + case Downloads.Impl.STATUS_BLOCKED: + return ERROR_BLOCKED; + default: return ERROR_UNKNOWN; } @@ -1333,7 +1332,6 @@ public class DownloadManager { case Downloads.Impl.STATUS_WAITING_TO_RETRY: case Downloads.Impl.STATUS_WAITING_FOR_NETWORK: case Downloads.Impl.STATUS_QUEUED_FOR_WIFI: - case Downloads.Impl.STATUS_PAUSED_BY_POLICY: return STATUS_PAUSED; case Downloads.Impl.STATUS_SUCCESS: diff --git a/core/java/android/net/INetworkPolicyListener.aidl b/core/java/android/net/INetworkPolicyListener.aidl index 92301510cc31..a45ec545d632 100644 --- a/core/java/android/net/INetworkPolicyListener.aidl +++ b/core/java/android/net/INetworkPolicyListener.aidl @@ -19,6 +19,7 @@ package android.net; /** {@hide} */ oneway interface INetworkPolicyListener { - void onRulesChanged(int uid, int uidRules); + void onUidRulesChanged(int uid, int uidRules); + void onMeteredIfacesChanged(in String[] meteredIfaces); } diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index 0d4d9a949e8c..bfea16804b33 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -34,13 +34,13 @@ public class NetworkPolicyManager { /** No specific network policy, use system default. */ public static final int POLICY_NONE = 0x0; - /** Reject network usage on paid networks when application in background. */ - public static final int POLICY_REJECT_PAID_BACKGROUND = 0x1; + /** Reject network usage on metered networks when application in background. */ + public static final int POLICY_REJECT_METERED_BACKGROUND = 0x1; /** All network traffic should be allowed. */ public static final int RULE_ALLOW_ALL = 0x0; - /** Reject traffic on paid networks. */ - public static final int RULE_REJECT_PAID = 0x1; + /** Reject traffic on metered networks. */ + public static final int RULE_REJECT_METERED = 0x1; /** * {@link Intent} action launched when user selects {@link NetworkPolicy} @@ -98,7 +98,7 @@ public class NetworkPolicyManager { * Set policy flags for specific UID. * * @param policy {@link #POLICY_NONE} or combination of flags like - * {@link #POLICY_REJECT_PAID_BACKGROUND}. + * {@link #POLICY_REJECT_METERED_BACKGROUND}. */ public void setUidPolicy(int uid, int policy) { try { @@ -217,8 +217,8 @@ public class NetworkPolicyManager { /** {@hide} */ public static void dumpPolicy(PrintWriter fout, int policy) { fout.write("["); - if ((policy & POLICY_REJECT_PAID_BACKGROUND) != 0) { - fout.write("REJECT_PAID_BACKGROUND"); + if ((policy & POLICY_REJECT_METERED_BACKGROUND) != 0) { + fout.write("REJECT_METERED_BACKGROUND"); } fout.write("]"); } @@ -226,8 +226,8 @@ public class NetworkPolicyManager { /** {@hide} */ public static void dumpRules(PrintWriter fout, int rules) { fout.write("["); - if ((rules & RULE_REJECT_PAID) != 0) { - fout.write("REJECT_PAID"); + if ((rules & RULE_REJECT_METERED) != 0) { + fout.write("REJECT_METERED"); } fout.write("]"); } diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java index 0a8c3ca48015..ba4804d10ecb 100644 --- a/core/java/android/provider/Downloads.java +++ b/core/java/android/provider/Downloads.java @@ -548,14 +548,6 @@ public final class Downloads { } /** - * This download has been paused because requesting application has been - * blocked by {@link NetworkPolicyManager}. - * - * @hide - */ - public static final int STATUS_PAUSED_BY_POLICY = 189; - - /** * This download hasn't stated yet */ public static final int STATUS_PENDING = 190; @@ -704,6 +696,14 @@ public final class Downloads { public static final int STATUS_TOO_MANY_REDIRECTS = 497; /** + * This download has failed because requesting application has been + * blocked by {@link NetworkPolicyManager}. + * + * @hide + */ + public static final int STATUS_BLOCKED = 498; + + /** * This download is visible but only shows in the notifications * while it's in progress. */ diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index 164c6578cc71..042120587dea 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -306,6 +306,8 @@ public class TextureView extends View { * <p><strong>Do not</strong> invoke this method from a drawing method * ({@link #onDraw(android.graphics.Canvas)} for instance).</p> * + * <p>If an error occurs during the copy, an empty bitmap will be returned.</p> + * * @return A valid {@link Bitmap.Config#ARGB_8888} bitmap, or null if the surface * texture is not available or the width <= 0 or the height <= 0 * @@ -328,6 +330,8 @@ public class TextureView extends View { * <p><strong>Do not</strong> invoke this method from a drawing method * ({@link #onDraw(android.graphics.Canvas)} for instance).</p> * + * <p>If an error occurs during the copy, an empty bitmap will be returned.</p> + * * @param width The width of the bitmap to create * @param height The height of the bitmap to create * @@ -354,6 +358,8 @@ public class TextureView extends View { * <p><strong>Do not</strong> invoke this method from a drawing method * ({@link #onDraw(android.graphics.Canvas)} for instance).</p> * + * <p>If an error occurs, the bitmap is left unchanged.</p> + * * @param bitmap The bitmap to copy the content of the surface texture into, * cannot be null, all configurations are supported * @@ -447,5 +453,6 @@ public class TextureView extends View { public void onSurfaceTextureDestroyed(SurfaceTexture surface); } - private static native void nSetDefaultBufferSize(SurfaceTexture surfaceTexture, int width, int height); + private static native void nSetDefaultBufferSize(SurfaceTexture surfaceTexture, + int width, int height); } diff --git a/core/java/android/view/ViewAncestor.java b/core/java/android/view/ViewAncestor.java index ba3ae5846619..afbedafa6eac 100644 --- a/core/java/android/view/ViewAncestor.java +++ b/core/java/android/view/ViewAncestor.java @@ -4479,7 +4479,7 @@ public final class ViewAncestor extends Handler implements ViewParent, ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList; foundViews.clear(); - View root = null; + View root; if (accessibilityViewId != View.NO_ID) { root = findViewByAccessibilityId(accessibilityViewId); } else { diff --git a/core/java/com/android/internal/widget/DigitalClock.java b/core/java/com/android/internal/widget/DigitalClock.java index 0885b6e37d29..ac0dc35d7577 100644 --- a/core/java/com/android/internal/widget/DigitalClock.java +++ b/core/java/com/android/internal/widget/DigitalClock.java @@ -96,13 +96,13 @@ public class DigitalClock extends RelativeLayout { }; static class AmPm { - private TextView mAmPm; + private TextView mAmPmTextView; private String mAmString, mPmString; AmPm(View parent, Typeface tf) { - mAmPm = (TextView) parent.findViewById(R.id.am_pm); - if (tf != null) { - mAmPm.setTypeface(tf); + mAmPmTextView = (TextView) parent.findViewById(R.id.am_pm); + if (mAmPmTextView != null && tf != null) { + mAmPmTextView.setTypeface(tf); } String[] ampm = new DateFormatSymbols().getAmPmStrings(); @@ -111,11 +111,15 @@ public class DigitalClock extends RelativeLayout { } void setShowAmPm(boolean show) { - mAmPm.setVisibility(show ? View.VISIBLE : View.GONE); + if (mAmPmTextView != null) { + mAmPmTextView.setVisibility(show ? View.VISIBLE : View.GONE); + } } void setIsMorning(boolean isMorning) { - mAmPm.setText(isMorning ? mAmString : mPmString); + if (mAmPmTextView != null) { + mAmPmTextView.setText(isMorning ? mAmString : mPmString); + } } } diff --git a/core/java/com/android/internal/widget/LockPatternView.java b/core/java/com/android/internal/widget/LockPatternView.java index bee8112923a5..cbb110a09120 100644 --- a/core/java/com/android/internal/widget/LockPatternView.java +++ b/core/java/com/android/internal/widget/LockPatternView.java @@ -131,6 +131,7 @@ public class LockPatternView extends View { private int mAspect; private final Matrix mArrowMatrix = new Matrix(); + private final Matrix mCircleMatrix = new Matrix(); /** * Represents a cell in the 3 X 3 matrix of the unlock pattern view. @@ -281,9 +282,14 @@ public class LockPatternView extends View { mBitmapArrowGreenUp = getBitmapFor(R.drawable.indicator_code_lock_drag_direction_green_up); mBitmapArrowRedUp = getBitmapFor(R.drawable.indicator_code_lock_drag_direction_red_up); - // we assume all bitmaps have the same size - mBitmapWidth = mBitmapBtnDefault.getWidth(); - mBitmapHeight = mBitmapBtnDefault.getHeight(); + // bitmaps have the size of the largest bitmap in this group + final Bitmap bitmaps[] = { mBitmapBtnDefault, mBitmapBtnTouched, mBitmapCircleDefault, + mBitmapCircleGreen, mBitmapCircleRed }; + + for (Bitmap bitmap : bitmaps) { + mBitmapWidth = Math.max(mBitmapWidth, bitmap.getWidth()); + mBitmapHeight = Math.max(mBitmapHeight, bitmap.getHeight()); + } // allow vibration pattern to be customized mVibePattern = loadVibratePattern(com.android.internal.R.array.config_virtualKeyVibePattern); @@ -458,31 +464,40 @@ public class LockPatternView extends View { break; case MeasureSpec.EXACTLY: default: - result = specSize; + // use the specified size, if non-zero + result = specSize != 0 ? specSize : desired; } return result; } @Override + protected int getSuggestedMinimumWidth() { + // View should be large enough to contain 3 side-by-side target bitmaps + return 3 * mBitmapWidth; + } + + @Override + protected int getSuggestedMinimumHeight() { + // View should be large enough to contain 3 side-by-side target bitmaps + return 3 * mBitmapWidth; + } + + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final int minimumWidth = 3 * mBitmapCircleDefault.getWidth(); - final int minimumHeight = 3 * mBitmapCircleDefault.getHeight(); + final int minimumWidth = getSuggestedMinimumWidth(); + final int minimumHeight = getSuggestedMinimumHeight(); int viewWidth = resolveMeasured(widthMeasureSpec, minimumWidth); int viewHeight = resolveMeasured(heightMeasureSpec, minimumHeight); - int requestedWidth = MeasureSpec.getSize(widthMeasureSpec); - int requestedHeight = MeasureSpec.getSize(heightMeasureSpec); switch (mAspect) { case ASPECT_SQUARE: - viewWidth = viewHeight = Math.min(requestedWidth, requestedHeight); + viewWidth = viewHeight = Math.min(viewWidth, viewHeight); break; case ASPECT_LOCK_WIDTH: - viewWidth = requestedWidth; - viewHeight = Math.min(requestedWidth, requestedHeight); + viewHeight = Math.min(viewWidth, viewHeight); break; case ASPECT_LOCK_HEIGHT: - viewWidth = Math.min(requestedWidth, requestedHeight); - viewHeight = requestedHeight; + viewWidth = Math.min(viewWidth, viewHeight); break; } // Log.v(TAG, "LockPatternView dimensions: " + viewWidth + "x" + viewHeight); @@ -603,51 +618,26 @@ public class LockPatternView extends View { } @Override - public boolean onTouchEvent(MotionEvent motionEvent) { + public boolean onTouchEvent(MotionEvent event) { if (!mInputEnabled || !isEnabled()) { return false; } - final float x = motionEvent.getX(); - final float y = motionEvent.getY(); - Cell hitCell; - switch(motionEvent.getAction()) { + switch(event.getAction()) { case MotionEvent.ACTION_DOWN: - resetPattern(); - hitCell = detectAndAddHit(x, y); - if (hitCell != null && mOnPatternListener != null) { - mPatternInProgress = true; - mPatternDisplayMode = DisplayMode.Correct; - mOnPatternListener.onPatternStart(); - } else if (mOnPatternListener != null) { - mPatternInProgress = false; - mOnPatternListener.onPatternCleared(); - } - if (hitCell != null) { - final float startX = getCenterXForColumn(hitCell.column); - final float startY = getCenterYForRow(hitCell.row); - - final float widthOffset = mSquareWidth / 2f; - final float heightOffset = mSquareHeight / 2f; - - invalidate((int) (startX - widthOffset), (int) (startY - heightOffset), - (int) (startX + widthOffset), (int) (startY + heightOffset)); - } - mInProgressX = x; - mInProgressY = y; - if (PROFILE_DRAWING) { - if (!mDrawingProfilingStarted) { - Debug.startMethodTracing("LockPatternDrawing"); - mDrawingProfilingStarted = true; - } - } + handleActionDown(event); return true; case MotionEvent.ACTION_UP: - // report pattern detected - if (!mPattern.isEmpty() && mOnPatternListener != null) { + handleActionUp(event); + return true; + case MotionEvent.ACTION_MOVE: + handleActionMove(event); + return true; + case MotionEvent.ACTION_CANCEL: + resetPattern(); + if (mOnPatternListener != null) { mPatternInProgress = false; - mOnPatternListener.onPatternDetected(mPattern); - invalidate(); + mOnPatternListener.onPatternCleared(); } if (PROFILE_DRAWING) { if (mDrawingProfilingStarted) { @@ -656,141 +646,183 @@ public class LockPatternView extends View { } } return true; - case MotionEvent.ACTION_MOVE: - final int patternSizePreHitDetect = mPattern.size(); - hitCell = detectAndAddHit(x, y); - final int patternSize = mPattern.size(); - if (hitCell != null && (mOnPatternListener != null) && (patternSize == 1)) { - mPatternInProgress = true; - mOnPatternListener.onPatternStart(); - } - // note current x and y for rubber banding of in progress - // patterns - final float dx = Math.abs(x - mInProgressX); - final float dy = Math.abs(y - mInProgressY); - if (dx + dy > mSquareWidth * 0.01f) { - float oldX = mInProgressX; - float oldY = mInProgressY; + } + return false; + } - mInProgressX = x; - mInProgressY = y; + private void handleActionMove(MotionEvent event) { + // Handle all recent motion events so we don't skip any cells even when the device + // is busy... + final int historySize = event.getHistorySize(); + for (int i = 0; i < historySize + 1; i++) { + final float x = i < historySize ? event.getHistoricalX(i) : event.getX(); + final float y = i < historySize ? event.getHistoricalY(i) : event.getY(); + final int patternSizePreHitDetect = mPattern.size(); + Cell hitCell = detectAndAddHit(x, y); + final int patternSize = mPattern.size(); + if (hitCell != null && (mOnPatternListener != null) && (patternSize == 1)) { + mPatternInProgress = true; + mOnPatternListener.onPatternStart(); + } + // note current x and y for rubber banding of in progress patterns + final float dx = Math.abs(x - mInProgressX); + final float dy = Math.abs(y - mInProgressY); + if (dx + dy > mSquareWidth * 0.01f) { + float oldX = mInProgressX; + float oldY = mInProgressY; - if (mPatternInProgress && patternSize > 0) { - final ArrayList<Cell> pattern = mPattern; - final float radius = mSquareWidth * mDiameterFactor * 0.5f; + mInProgressX = x; + mInProgressY = y; - final Cell lastCell = pattern.get(patternSize - 1); + if (mPatternInProgress && patternSize > 0) { + final ArrayList<Cell> pattern = mPattern; + final float radius = mSquareWidth * mDiameterFactor * 0.5f; - float startX = getCenterXForColumn(lastCell.column); - float startY = getCenterYForRow(lastCell.row); + final Cell lastCell = pattern.get(patternSize - 1); - float left; - float top; - float right; - float bottom; + float startX = getCenterXForColumn(lastCell.column); + float startY = getCenterYForRow(lastCell.row); - final Rect invalidateRect = mInvalidate; + float left; + float top; + float right; + float bottom; - if (startX < x) { - left = startX; - right = x; - } else { - left = x; - right = startX; - } + final Rect invalidateRect = mInvalidate; - if (startY < y) { - top = startY; - bottom = y; - } else { - top = y; - bottom = startY; - } + if (startX < x) { + left = startX; + right = x; + } else { + left = x; + right = startX; + } - // Invalidate between the pattern's last cell and the current location - invalidateRect.set((int) (left - radius), (int) (top - radius), - (int) (right + radius), (int) (bottom + radius)); + if (startY < y) { + top = startY; + bottom = y; + } else { + top = y; + bottom = startY; + } - if (startX < oldX) { - left = startX; - right = oldX; - } else { - left = oldX; - right = startX; - } + // Invalidate between the pattern's last cell and the current location + invalidateRect.set((int) (left - radius), (int) (top - radius), + (int) (right + radius), (int) (bottom + radius)); - if (startY < oldY) { - top = startY; - bottom = oldY; - } else { - top = oldY; - bottom = startY; - } + if (startX < oldX) { + left = startX; + right = oldX; + } else { + left = oldX; + right = startX; + } + + if (startY < oldY) { + top = startY; + bottom = oldY; + } else { + top = oldY; + bottom = startY; + } + + // Invalidate between the pattern's last cell and the previous location + invalidateRect.union((int) (left - radius), (int) (top - radius), + (int) (right + radius), (int) (bottom + radius)); + + // Invalidate between the pattern's new cell and the pattern's previous cell + if (hitCell != null) { + startX = getCenterXForColumn(hitCell.column); + startY = getCenterYForRow(hitCell.row); + + if (patternSize >= 2) { + // (re-using hitcell for old cell) + hitCell = pattern.get(patternSize - 1 - (patternSize - patternSizePreHitDetect)); + oldX = getCenterXForColumn(hitCell.column); + oldY = getCenterYForRow(hitCell.row); - // Invalidate between the pattern's last cell and the previous location - invalidateRect.union((int) (left - radius), (int) (top - radius), - (int) (right + radius), (int) (bottom + radius)); - - // Invalidate between the pattern's new cell and the pattern's previous cell - if (hitCell != null) { - startX = getCenterXForColumn(hitCell.column); - startY = getCenterYForRow(hitCell.row); - - if (patternSize >= 2) { - // (re-using hitcell for old cell) - hitCell = pattern.get(patternSize - 1 - (patternSize - patternSizePreHitDetect)); - oldX = getCenterXForColumn(hitCell.column); - oldY = getCenterYForRow(hitCell.row); - - if (startX < oldX) { - left = startX; - right = oldX; - } else { - left = oldX; - right = startX; - } - - if (startY < oldY) { - top = startY; - bottom = oldY; - } else { - top = oldY; - bottom = startY; - } + if (startX < oldX) { + left = startX; + right = oldX; } else { - left = right = startX; - top = bottom = startY; + left = oldX; + right = startX; } - final float widthOffset = mSquareWidth / 2f; - final float heightOffset = mSquareHeight / 2f; - - invalidateRect.set((int) (left - widthOffset), - (int) (top - heightOffset), (int) (right + widthOffset), - (int) (bottom + heightOffset)); + if (startY < oldY) { + top = startY; + bottom = oldY; + } else { + top = oldY; + bottom = startY; + } + } else { + left = right = startX; + top = bottom = startY; } - invalidate(invalidateRect); - } else { - invalidate(); - } - } - return true; - case MotionEvent.ACTION_CANCEL: - resetPattern(); - if (mOnPatternListener != null) { - mPatternInProgress = false; - mOnPatternListener.onPatternCleared(); - } - if (PROFILE_DRAWING) { - if (mDrawingProfilingStarted) { - Debug.stopMethodTracing(); - mDrawingProfilingStarted = false; + final float widthOffset = mSquareWidth / 2f; + final float heightOffset = mSquareHeight / 2f; + + invalidateRect.set((int) (left - widthOffset), + (int) (top - heightOffset), (int) (right + widthOffset), + (int) (bottom + heightOffset)); } + + invalidate(invalidateRect); + } else { + invalidate(); } - return true; + } + } + } + + private void handleActionUp(MotionEvent event) { + // report pattern detected + if (!mPattern.isEmpty() && mOnPatternListener != null) { + mPatternInProgress = false; + mOnPatternListener.onPatternDetected(mPattern); + invalidate(); + } + if (PROFILE_DRAWING) { + if (mDrawingProfilingStarted) { + Debug.stopMethodTracing(); + mDrawingProfilingStarted = false; + } + } + } + + private void handleActionDown(MotionEvent event) { + resetPattern(); + final float x = event.getX(); + final float y = event.getY(); + final Cell hitCell = detectAndAddHit(x, y); + if (hitCell != null && mOnPatternListener != null) { + mPatternInProgress = true; + mPatternDisplayMode = DisplayMode.Correct; + mOnPatternListener.onPatternStart(); + } else if (mOnPatternListener != null) { + mPatternInProgress = false; + mOnPatternListener.onPatternCleared(); + } + if (hitCell != null) { + final float startX = getCenterXForColumn(hitCell.column); + final float startY = getCenterYForRow(hitCell.row); + + final float widthOffset = mSquareWidth / 2f; + final float heightOffset = mSquareHeight / 2f; + + invalidate((int) (startX - widthOffset), (int) (startY - heightOffset), + (int) (startX + widthOffset), (int) (startY + heightOffset)); + } + mInProgressX = x; + mInProgressY = y; + if (PROFILE_DRAWING) { + if (!mDrawingProfilingStarted) { + Debug.startMethodTracing("LockPatternDrawing"); + mDrawingProfilingStarted = true; + } } - return false; } private float getCenterXForColumn(int column) { @@ -947,8 +979,8 @@ public class LockPatternView extends View { // This assumes that the arrow image is drawn at 12:00 with it's top edge // coincident with the circle bitmap's top edge. Bitmap arrow = green ? mBitmapArrowGreenUp : mBitmapArrowRedUp; - final int cellWidth = mBitmapCircleDefault.getWidth(); - final int cellHeight = mBitmapCircleDefault.getHeight(); + final int cellWidth = mBitmapWidth; + final int cellHeight = mBitmapHeight; // the up arrow bitmap is at 12:00, so find the rotation from x axis and add 90 degrees. final float theta = (float) Math.atan2( @@ -956,7 +988,12 @@ public class LockPatternView extends View { final float angle = (float) Math.toDegrees(theta) + 90.0f; // compose matrix + float sx = Math.min(mSquareWidth / mBitmapWidth, 1.0f); + float sy = Math.min(mSquareHeight / mBitmapHeight, 1.0f); mArrowMatrix.setTranslate(leftX + offsetX, topY + offsetY); // transform to cell position + mArrowMatrix.preTranslate(mBitmapWidth/2, mBitmapHeight/2); + mArrowMatrix.preScale(sx, sy); + mArrowMatrix.preTranslate(-mBitmapWidth/2, -mBitmapHeight/2); mArrowMatrix.preRotate(angle, cellWidth / 2.0f, cellHeight / 2.0f); // rotate about cell center mArrowMatrix.preTranslate((cellWidth - arrow.getWidth()) / 2.0f, 0.0f); // translate to 12:00 pos canvas.drawBitmap(arrow, mArrowMatrix, mPaint); @@ -1002,8 +1039,17 @@ public class LockPatternView extends View { int offsetX = (int) ((squareWidth - width) / 2f); int offsetY = (int) ((squareHeight - height) / 2f); - canvas.drawBitmap(outerCircle, leftX + offsetX, topY + offsetY, mPaint); - canvas.drawBitmap(innerCircle, leftX + offsetX, topY + offsetY, mPaint); + // Allow circles to shrink if the view is too small to hold them. + float sx = Math.min(mSquareWidth / mBitmapWidth, 1.0f); + float sy = Math.min(mSquareHeight / mBitmapHeight, 1.0f); + + mCircleMatrix.setTranslate(leftX + offsetX, topY + offsetY); + mCircleMatrix.preTranslate(mBitmapWidth/2, mBitmapHeight/2); + mCircleMatrix.preScale(sx, sy); + mCircleMatrix.preTranslate(-mBitmapWidth/2, -mBitmapHeight/2); + + canvas.drawBitmap(outerCircle, mCircleMatrix, mPaint); + canvas.drawBitmap(innerCircle, mCircleMatrix, mPaint); } @Override diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index a8aff376d8bb..47902a8bc2ac 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -91,6 +91,8 @@ <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" /> + <protected-broadcast android:name="android.net.vpn.action.REVOKED" /> + <protected-broadcast android:name="android.nfc.action.LLCP_LINK_STATE_CHANGED" /> <protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_ON_DETECTED" /> <protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_OFF_DETECTED" /> diff --git a/core/res/res/drawable-hdpi/btn_code_lock_default_holo.png b/core/res/res/drawable-hdpi/btn_code_lock_default_holo.png Binary files differnew file mode 100644 index 000000000000..94d27cf3df3e --- /dev/null +++ b/core/res/res/drawable-hdpi/btn_code_lock_default_holo.png diff --git a/core/res/res/drawable-hdpi/btn_code_lock_touched_holo.png b/core/res/res/drawable-hdpi/btn_code_lock_touched_holo.png Binary files differnew file mode 100644 index 000000000000..94d27cf3df3e --- /dev/null +++ b/core/res/res/drawable-hdpi/btn_code_lock_touched_holo.png diff --git a/core/res/res/drawable-hdpi/ic_lock_idle_alarm.png b/core/res/res/drawable-hdpi/ic_lock_idle_alarm.png Binary files differindex 6b4f66d24f80..3cadaff0f798 100644 --- a/core/res/res/drawable-hdpi/ic_lock_idle_alarm.png +++ b/core/res/res/drawable-hdpi/ic_lock_idle_alarm.png diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_emergencycall_normal.png b/core/res/res/drawable-hdpi/ic_lockscreen_emergencycall_normal.png Binary files differnew file mode 100644 index 000000000000..460495af2c30 --- /dev/null +++ b/core/res/res/drawable-hdpi/ic_lockscreen_emergencycall_normal.png diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_emergencycall_pressed.png b/core/res/res/drawable-hdpi/ic_lockscreen_emergencycall_pressed.png Binary files differnew file mode 100644 index 000000000000..b0f7ae97a1ae --- /dev/null +++ b/core/res/res/drawable-hdpi/ic_lockscreen_emergencycall_pressed.png diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_forgotpassword_normal.png b/core/res/res/drawable-hdpi/ic_lockscreen_forgotpassword_normal.png Binary files differnew file mode 100644 index 000000000000..6402d3d428b0 --- /dev/null +++ b/core/res/res/drawable-hdpi/ic_lockscreen_forgotpassword_normal.png diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_forgotpassword_pressed.png b/core/res/res/drawable-hdpi/ic_lockscreen_forgotpassword_pressed.png Binary files differnew file mode 100644 index 000000000000..83be04650a0b --- /dev/null +++ b/core/res/res/drawable-hdpi/ic_lockscreen_forgotpassword_pressed.png diff --git a/core/res/res/drawable-hdpi/indicator_code_lock_drag_direction_green_up_holo.png b/core/res/res/drawable-hdpi/indicator_code_lock_drag_direction_green_up_holo.png Binary files differnew file mode 100644 index 000000000000..a68697507a7e --- /dev/null +++ b/core/res/res/drawable-hdpi/indicator_code_lock_drag_direction_green_up_holo.png diff --git a/core/res/res/drawable-hdpi/indicator_code_lock_drag_direction_red_up_holo.png b/core/res/res/drawable-hdpi/indicator_code_lock_drag_direction_red_up_holo.png Binary files differnew file mode 100644 index 000000000000..92db8efa14d7 --- /dev/null +++ b/core/res/res/drawable-hdpi/indicator_code_lock_drag_direction_red_up_holo.png diff --git a/core/res/res/drawable-hdpi/indicator_code_lock_point_area_default_holo.png b/core/res/res/drawable-hdpi/indicator_code_lock_point_area_default_holo.png Binary files differnew file mode 100644 index 000000000000..237011c16b44 --- /dev/null +++ b/core/res/res/drawable-hdpi/indicator_code_lock_point_area_default_holo.png diff --git a/core/res/res/drawable-hdpi/indicator_code_lock_point_area_green_holo.png b/core/res/res/drawable-hdpi/indicator_code_lock_point_area_green_holo.png Binary files differnew file mode 100644 index 000000000000..24180178097d --- /dev/null +++ b/core/res/res/drawable-hdpi/indicator_code_lock_point_area_green_holo.png diff --git a/core/res/res/drawable-hdpi/indicator_code_lock_point_area_red_holo.png b/core/res/res/drawable-hdpi/indicator_code_lock_point_area_red_holo.png Binary files differnew file mode 100644 index 000000000000..2120bad70380 --- /dev/null +++ b/core/res/res/drawable-hdpi/indicator_code_lock_point_area_red_holo.png diff --git a/core/res/res/drawable-mdpi/btn_code_lock_default.png b/core/res/res/drawable-mdpi/btn_code_lock_default.png Binary files differindex 45cc20dd6ddf..f524317d33f8 100644..100755 --- a/core/res/res/drawable-mdpi/btn_code_lock_default.png +++ b/core/res/res/drawable-mdpi/btn_code_lock_default.png diff --git a/core/res/res/drawable-mdpi/btn_code_lock_default_holo.png b/core/res/res/drawable-mdpi/btn_code_lock_default_holo.png Binary files differnew file mode 100644 index 000000000000..7d11275a7e92 --- /dev/null +++ b/core/res/res/drawable-mdpi/btn_code_lock_default_holo.png diff --git a/core/res/res/drawable-mdpi/btn_code_lock_touched.png b/core/res/res/drawable-mdpi/btn_code_lock_touched.png Binary files differindex 45cc20dd6ddf..5cd436c0b889 100644..100755 --- a/core/res/res/drawable-mdpi/btn_code_lock_touched.png +++ b/core/res/res/drawable-mdpi/btn_code_lock_touched.png diff --git a/core/res/res/drawable-mdpi/btn_code_lock_touched_holo.png b/core/res/res/drawable-mdpi/btn_code_lock_touched_holo.png Binary files differnew file mode 100644 index 000000000000..7d11275a7e92 --- /dev/null +++ b/core/res/res/drawable-mdpi/btn_code_lock_touched_holo.png diff --git a/core/res/res/drawable-mdpi/ic_lock_idle_alarm.png b/core/res/res/drawable-mdpi/ic_lock_idle_alarm.png Binary files differindex 97ac02361a2d..b5d3e0980551 100644 --- a/core/res/res/drawable-mdpi/ic_lock_idle_alarm.png +++ b/core/res/res/drawable-mdpi/ic_lock_idle_alarm.png diff --git a/core/res/res/drawable-mdpi/ic_lock_idle_charging.png b/core/res/res/drawable-mdpi/ic_lock_idle_charging.png Binary files differindex 4210db26765a..20d632068c39 100644..100755 --- a/core/res/res/drawable-mdpi/ic_lock_idle_charging.png +++ b/core/res/res/drawable-mdpi/ic_lock_idle_charging.png diff --git a/core/res/res/drawable-mdpi/ic_lock_idle_lock.png b/core/res/res/drawable-mdpi/ic_lock_idle_lock.png Binary files differindex 1060f5a8da15..0206aeef6883 100644..100755 --- a/core/res/res/drawable-mdpi/ic_lock_idle_lock.png +++ b/core/res/res/drawable-mdpi/ic_lock_idle_lock.png diff --git a/core/res/res/drawable-mdpi/ic_lock_idle_low_battery.png b/core/res/res/drawable-mdpi/ic_lock_idle_low_battery.png Binary files differindex 72e4afa14bec..bb967829d234 100644..100755 --- a/core/res/res/drawable-mdpi/ic_lock_idle_low_battery.png +++ b/core/res/res/drawable-mdpi/ic_lock_idle_low_battery.png diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_emergencycall_normal.png b/core/res/res/drawable-mdpi/ic_lockscreen_emergencycall_normal.png Binary files differnew file mode 100644 index 000000000000..cae795fd7547 --- /dev/null +++ b/core/res/res/drawable-mdpi/ic_lockscreen_emergencycall_normal.png diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_emergencycall_pressed.png b/core/res/res/drawable-mdpi/ic_lockscreen_emergencycall_pressed.png Binary files differnew file mode 100644 index 000000000000..28679564935b --- /dev/null +++ b/core/res/res/drawable-mdpi/ic_lockscreen_emergencycall_pressed.png diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_forgotpassword_normal.png b/core/res/res/drawable-mdpi/ic_lockscreen_forgotpassword_normal.png Binary files differnew file mode 100644 index 000000000000..a7e063a5c8c1 --- /dev/null +++ b/core/res/res/drawable-mdpi/ic_lockscreen_forgotpassword_normal.png diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_forgotpassword_pressed.png b/core/res/res/drawable-mdpi/ic_lockscreen_forgotpassword_pressed.png Binary files differnew file mode 100644 index 000000000000..53af5a54faa5 --- /dev/null +++ b/core/res/res/drawable-mdpi/ic_lockscreen_forgotpassword_pressed.png diff --git a/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_green_up.png b/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_green_up.png Binary files differindex 0bc86c36a70a..7ddeba529748 100644 --- a/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_green_up.png +++ b/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_green_up.png diff --git a/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_green_up_holo.png b/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_green_up_holo.png Binary files differnew file mode 100644 index 000000000000..89d209c3c724 --- /dev/null +++ b/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_green_up_holo.png diff --git a/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_red_up.png b/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_red_up.png Binary files differindex 2ab45477a1b8..7201e58a81c0 100644 --- a/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_red_up.png +++ b/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_red_up.png diff --git a/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_red_up_holo.png b/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_red_up_holo.png Binary files differnew file mode 100644 index 000000000000..1d4cb32100d1 --- /dev/null +++ b/core/res/res/drawable-mdpi/indicator_code_lock_drag_direction_red_up_holo.png diff --git a/core/res/res/drawable-mdpi/indicator_code_lock_point_area_default_holo.png b/core/res/res/drawable-mdpi/indicator_code_lock_point_area_default_holo.png Binary files differnew file mode 100644 index 000000000000..a627cda96b02 --- /dev/null +++ b/core/res/res/drawable-mdpi/indicator_code_lock_point_area_default_holo.png diff --git a/core/res/res/drawable-mdpi/indicator_code_lock_point_area_green_holo.png b/core/res/res/drawable-mdpi/indicator_code_lock_point_area_green_holo.png Binary files differnew file mode 100644 index 000000000000..308624bce110 --- /dev/null +++ b/core/res/res/drawable-mdpi/indicator_code_lock_point_area_green_holo.png diff --git a/core/res/res/drawable-mdpi/indicator_code_lock_point_area_red_holo.png b/core/res/res/drawable-mdpi/indicator_code_lock_point_area_red_holo.png Binary files differnew file mode 100644 index 000000000000..6c451ec5389a --- /dev/null +++ b/core/res/res/drawable-mdpi/indicator_code_lock_point_area_red_holo.png diff --git a/core/res/res/drawable-xhdpi/ic_lock_idle_alarm.png b/core/res/res/drawable-xhdpi/ic_lock_idle_alarm.png Binary files differnew file mode 100644 index 000000000000..2822a922fa48 --- /dev/null +++ b/core/res/res/drawable-xhdpi/ic_lock_idle_alarm.png diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_emergencycall_normal.png b/core/res/res/drawable-xhdpi/ic_lockscreen_emergencycall_normal.png Binary files differnew file mode 100644 index 000000000000..a61f7a518d32 --- /dev/null +++ b/core/res/res/drawable-xhdpi/ic_lockscreen_emergencycall_normal.png diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_emergencycall_pressed.png b/core/res/res/drawable-xhdpi/ic_lockscreen_emergencycall_pressed.png Binary files differnew file mode 100644 index 000000000000..dd5e4815b5d9 --- /dev/null +++ b/core/res/res/drawable-xhdpi/ic_lockscreen_emergencycall_pressed.png diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_forgotpassword_normal.png b/core/res/res/drawable-xhdpi/ic_lockscreen_forgotpassword_normal.png Binary files differnew file mode 100644 index 000000000000..e4172ce65002 --- /dev/null +++ b/core/res/res/drawable-xhdpi/ic_lockscreen_forgotpassword_normal.png diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_forgotpassword_pressed.png b/core/res/res/drawable-xhdpi/ic_lockscreen_forgotpassword_pressed.png Binary files differnew file mode 100644 index 000000000000..e2c76217f128 --- /dev/null +++ b/core/res/res/drawable-xhdpi/ic_lockscreen_forgotpassword_pressed.png diff --git a/core/res/res/drawable-xhdpi/indicator_code_lock_point_area_default_holo.png b/core/res/res/drawable-xhdpi/indicator_code_lock_point_area_default_holo.png Binary files differnew file mode 100644 index 000000000000..d98a126327c2 --- /dev/null +++ b/core/res/res/drawable-xhdpi/indicator_code_lock_point_area_default_holo.png diff --git a/core/res/res/drawable-xhdpi/indicator_code_lock_point_area_green_holo.png b/core/res/res/drawable-xhdpi/indicator_code_lock_point_area_green_holo.png Binary files differnew file mode 100644 index 000000000000..4491f02f9b5f --- /dev/null +++ b/core/res/res/drawable-xhdpi/indicator_code_lock_point_area_green_holo.png diff --git a/core/res/res/drawable-xhdpi/indicator_code_lock_point_area_red_holo.png b/core/res/res/drawable-xhdpi/indicator_code_lock_point_area_red_holo.png Binary files differnew file mode 100644 index 000000000000..6e91fbcdf62a --- /dev/null +++ b/core/res/res/drawable-xhdpi/indicator_code_lock_point_area_red_holo.png diff --git a/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_alarm.png b/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_alarm.png Binary files differnew file mode 100644 index 000000000000..29cd47139d72 --- /dev/null +++ b/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_alarm.png diff --git a/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_charging.png b/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_charging.png Binary files differnew file mode 100644 index 000000000000..211aa0b996a0 --- /dev/null +++ b/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_charging.png diff --git a/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_lock.png b/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_lock.png Binary files differnew file mode 100644 index 000000000000..683ba22ce052 --- /dev/null +++ b/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_lock.png diff --git a/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_low_battery.png b/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_low_battery.png Binary files differnew file mode 100644 index 000000000000..f4383f3a2f8c --- /dev/null +++ b/core/res/res/drawable-xlarge-hdpi/ic_lock_idle_low_battery.png diff --git a/core/res/res/drawable-xlarge-mdpi/btn_code_lock_default.png b/core/res/res/drawable-xlarge-mdpi/btn_code_lock_default.png Binary files differnew file mode 100644 index 000000000000..45cc20dd6ddf --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/btn_code_lock_default.png diff --git a/core/res/res/drawable-xlarge-mdpi/btn_code_lock_touched.png b/core/res/res/drawable-xlarge-mdpi/btn_code_lock_touched.png Binary files differnew file mode 100644 index 000000000000..45cc20dd6ddf --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/btn_code_lock_touched.png diff --git a/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_alarm.png b/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_alarm.png Binary files differnew file mode 100644 index 000000000000..97ac02361a2d --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_alarm.png diff --git a/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_charging.png b/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_charging.png Binary files differnew file mode 100644 index 000000000000..4210db26765a --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_charging.png diff --git a/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_lock.png b/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_lock.png Binary files differnew file mode 100644 index 000000000000..1060f5a8da15 --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_lock.png diff --git a/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_low_battery.png b/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_low_battery.png Binary files differnew file mode 100644 index 000000000000..72e4afa14bec --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/ic_lock_idle_low_battery.png diff --git a/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_drag_direction_green_up.png b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_drag_direction_green_up.png Binary files differnew file mode 100644 index 000000000000..0bc86c36a70a --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_drag_direction_green_up.png diff --git a/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_drag_direction_red_up.png b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_drag_direction_red_up.png Binary files differnew file mode 100644 index 000000000000..2ab45477a1b8 --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_drag_direction_red_up.png diff --git a/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_point_area_default.png b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_point_area_default.png Binary files differnew file mode 100644 index 000000000000..fe72d000d4bf --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_point_area_default.png diff --git a/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_point_area_green.png b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_point_area_green.png Binary files differnew file mode 100644 index 000000000000..be666c6f553c --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_point_area_green.png diff --git a/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_point_area_red.png b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_point_area_red.png Binary files differnew file mode 100644 index 000000000000..962719725f26 --- /dev/null +++ b/core/res/res/drawable-xlarge-mdpi/indicator_code_lock_point_area_red.png diff --git a/core/res/res/drawable-xlarge-xhdpi/indicator_code_lock_point_area_default.png b/core/res/res/drawable-xlarge-xhdpi/indicator_code_lock_point_area_default.png Binary files differnew file mode 100644 index 000000000000..6662eb16c7e6 --- /dev/null +++ b/core/res/res/drawable-xlarge-xhdpi/indicator_code_lock_point_area_default.png diff --git a/core/res/res/drawable-xlarge-xhdpi/indicator_code_lock_point_area_green.png b/core/res/res/drawable-xlarge-xhdpi/indicator_code_lock_point_area_green.png Binary files differnew file mode 100644 index 000000000000..dce220a98a97 --- /dev/null +++ b/core/res/res/drawable-xlarge-xhdpi/indicator_code_lock_point_area_green.png diff --git a/core/res/res/drawable-xlarge-xhdpi/indicator_code_lock_point_area_red.png b/core/res/res/drawable-xlarge-xhdpi/indicator_code_lock_point_area_red.png Binary files differnew file mode 100644 index 000000000000..746a3ea415b2 --- /dev/null +++ b/core/res/res/drawable-xlarge-xhdpi/indicator_code_lock_point_area_red.png diff --git a/core/res/res/drawable/lockscreen_emergency_button.xml b/core/res/res/drawable/lockscreen_emergency_button.xml new file mode 100644 index 000000000000..4ec6a963e1da --- /dev/null +++ b/core/res/res/drawable/lockscreen_emergency_button.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2008 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_enabled="true" android:drawable="@drawable/ic_lockscreen_emergencycall_normal" /> + <item android:state_pressed="true" android:drawable="@drawable/ic_lockscreen_emergencycall_pressed" /> + <item android:drawable="@drawable/ic_lockscreen_emergencycall_normal" /> +</selector> diff --git a/core/res/res/drawable/lockscreen_forgot_password_button.xml b/core/res/res/drawable/lockscreen_forgot_password_button.xml new file mode 100644 index 000000000000..6c081bf2c948 --- /dev/null +++ b/core/res/res/drawable/lockscreen_forgot_password_button.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2008 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_enabled="true" android:drawable="@drawable/ic_lockscreen_forgotpassword_normal" /> + <item android:state_pressed="true" android:drawable="@drawable/ic_lockscreen_forgotpassword_pressed" /> + <item android:drawable="@drawable/ic_lockscreen_forgotpassword_normal" /> +</selector> diff --git a/core/res/res/layout-sw600dp/keyguard_screen_status_land.xml b/core/res/res/layout-sw600dp/keyguard_screen_status_land.xml index 0a485e2fd0d1..302ee01c920e 100644 --- a/core/res/res/layout-sw600dp/keyguard_screen_status_land.xml +++ b/core/res/res/layout-sw600dp/keyguard_screen_status_land.xml @@ -56,7 +56,7 @@ android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="none" - android:textSize="98sp" + android:textSize="@dimen/keyguard_pattern_unlock_clock_font_size" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/lockscreen_clock_background" android:layout_marginBottom="6dip" @@ -67,7 +67,7 @@ android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="none" - android:textSize="98sp" + android:textSize="@dimen/keyguard_pattern_unlock_clock_font_size" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/lockscreen_clock_foreground" android:layout_alignLeft="@id/timeDisplayBackground" diff --git a/core/res/res/layout-sw600dp/keyguard_screen_status_port.xml b/core/res/res/layout-sw600dp/keyguard_screen_status_port.xml index 346b21e87b84..53fe902796cf 100644 --- a/core/res/res/layout-sw600dp/keyguard_screen_status_port.xml +++ b/core/res/res/layout-sw600dp/keyguard_screen_status_port.xml @@ -55,7 +55,7 @@ android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="none" - android:textSize="98sp" + android:textSize="@dimen/keyguard_pattern_unlock_clock_font_size" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/lockscreen_clock_background" android:layout_marginBottom="6dip" @@ -66,7 +66,7 @@ android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="none" - android:textSize="98sp" + android:textSize="@dimen/keyguard_pattern_unlock_clock_font_size" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/lockscreen_clock_foreground" android:layout_marginBottom="6dip" diff --git a/core/res/res/layout-sw600dp/keyguard_screen_unlock_landscape.xml b/core/res/res/layout-sw600dp/keyguard_screen_unlock_landscape.xml index e3d7a3f8ee3b..7ac41b5f1913 100644 --- a/core/res/res/layout-sw600dp/keyguard_screen_unlock_landscape.xml +++ b/core/res/res/layout-sw600dp/keyguard_screen_unlock_landscape.xml @@ -56,10 +56,8 @@ android:layout_gravity="center_vertical" /> - <!-- footer --> - - <!-- option 1: a single emergency call button --> - <RelativeLayout android:id="@+id/footerNormal" + <!-- Emergency and forgot pattern buttons. --> + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/lockPattern" @@ -68,43 +66,27 @@ android:layout_marginTop="28dip" android:layout_marginLeft="28dip" android:layout_marginRight="28dip" - > - <Button android:id="@+id/emergencyCallAlone" + android:orientation="horizontal"> + + <Button android:id="@+id/forgotPatternButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/lockscreen_emergency_call" + android:layout_gravity="center" style="@style/Widget.Button.Transparent" android:drawableLeft="@drawable/ic_emergency" android:drawablePadding="8dip" + android:text="@string/lockscreen_forgot_pattern_button_text" android:visibility="gone" - /> - </RelativeLayout> - - <!-- option 2: an emergency call button, and a 'forgot pattern?' button --> - <LinearLayout android:id="@+id/footerForgotPattern" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_below="@id/footerNormal" - android:layout_alignLeft="@id/lockPattern" - android:layout_alignRight="@id/lockPattern" - android:layout_marginTop="28dip" - android:layout_marginLeft="28dip" - android:layout_marginRight="28dip"> - - <Button android:id="@+id/forgotPattern" - android:layout_width="match_parent" - android:layout_height="wrap_content" - style="@style/Widget.Button.Transparent" /> - <Button android:id="@+id/emergencyCallTogether" - android:layout_width="match_parent" + <Button android:id="@+id/emergencyCallButton" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/lockscreen_emergency_call" + android:layout_gravity="center" style="@style/Widget.Button.Transparent" android:drawableLeft="@drawable/ic_emergency" android:drawablePadding="8dip" + android:text="@string/lockscreen_emergency_call" android:visibility="gone" /> diff --git a/core/res/res/layout-sw600dp/keyguard_screen_unlock_portrait.xml b/core/res/res/layout-sw600dp/keyguard_screen_unlock_portrait.xml index f35897e2425d..1f6058fc2fab 100644 --- a/core/res/res/layout-sw600dp/keyguard_screen_unlock_portrait.xml +++ b/core/res/res/layout-sw600dp/keyguard_screen_unlock_portrait.xml @@ -23,7 +23,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - <!-- top: status --> + <!-- top: status and emergency/forgot pattern buttons --> <LinearLayout android:layout_height="0dip" android:layout_weight="1" @@ -36,53 +36,37 @@ android:layout_marginTop="134dip" android:layout_marginLeft="266dip"/> - <!-- footer --> - <FrameLayout + <!-- Emergency and forgot pattern buttons. --> + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginLeft="140dip" - > + android:orientation="horizontal" + android:gravity="center_horizontal"> - <!-- option 1: a single emergency call button --> - <RelativeLayout android:id="@+id/footerNormal" - android:layout_width="match_parent" + <Button android:id="@+id/forgotPatternButton" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:gravity="left" - > - <Button android:id="@+id/emergencyCallAlone" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/lockscreen_emergency_call" - style="@style/Widget.Button.Transparent" - android:drawableLeft="@drawable/ic_emergency" - android:drawablePadding="8dip" - android:visibility="gone" - /> - </RelativeLayout> + android:layout_gravity="center" + style="@style/Widget.Button.Transparent" + android:drawableLeft="@drawable/ic_emergency" + android:drawablePadding="8dip" + android:text="@string/lockscreen_forgot_pattern_button_text" + android:visibility="gone" + /> - <!-- option 2: an emergency call button, and a 'forgot pattern?' button --> - <LinearLayout android:id="@+id/footerForgotPattern" - android:orientation="vertical" - android:layout_width="match_parent" + <Button android:id="@+id/emergencyCallButton" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:gravity="left" - > - <Button android:id="@+id/forgotPattern" - android:layout_width="match_parent" - android:layout_height="wrap_content" - style="@style/Widget.Button.Transparent" - /> - <Button android:id="@+id/emergencyCallTogether" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/lockscreen_emergency_call" - style="@style/Widget.Button.Transparent" - android:drawableLeft="@drawable/ic_emergency" - android:drawablePadding="8dip" - android:visibility="gone" - /> - </LinearLayout> - </FrameLayout> + android:layout_gravity="center" + style="@style/Widget.Button.Transparent" + android:drawableLeft="@drawable/ic_emergency" + android:drawablePadding="8dip" + android:text="@string/lockscreen_emergency_call" + android:visibility="gone" + /> + + </LinearLayout> + </LinearLayout> <!-- right side: lock pattern --> diff --git a/core/res/res/layout/keyguard_screen_status_land.xml b/core/res/res/layout/keyguard_screen_status_land.xml index 259a3afa57a7..8a02e1f206b7 100644 --- a/core/res/res/layout/keyguard_screen_status_land.xml +++ b/core/res/res/layout/keyguard_screen_status_land.xml @@ -133,16 +133,4 @@ android:textAppearance="?android:attr/textAppearanceMedium" /> - <TextView - android:id="@+id/propertyOf" - android:lineSpacingExtra="8dip" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="17sp" - android:layout_marginTop="20dip" - android:singleLine="false" - android:textColor="@color/lockscreen_owner_info" - android:visibility="gone" - /> </LinearLayout> diff --git a/core/res/res/layout/keyguard_screen_status_port.xml b/core/res/res/layout/keyguard_screen_status_port.xml index 680c07360dab..1e87fb396614 100644 --- a/core/res/res/layout/keyguard_screen_status_port.xml +++ b/core/res/res/layout/keyguard_screen_status_port.xml @@ -130,16 +130,4 @@ android:textAppearance="?android:attr/textAppearanceMedium" /> - <TextView - android:id="@+id/propertyOf" - android:lineSpacingExtra="8dip" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="20dip" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="17sp" - android:singleLine="false" - android:visibility="gone" - android:textColor="@color/lockscreen_owner_info" - /> </LinearLayout> diff --git a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml index df29a4b3c09e..d45cc859968f 100644 --- a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml +++ b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml @@ -20,154 +20,155 @@ <!-- This is the general lock screen which shows information about the state of the device, as well as instructions on how to get past it depending on the state of the device.--> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="horizontal" + android:orientation="vertical" + android:rowCount="10" android:id="@+id/root" android:clipChildren="false"> - <!-- left side --> - <RelativeLayout - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1.0" - android:layout_marginLeft="24dip" - android:gravity="left"> + <!-- Column 0 --> + <Space android:height="20dip"/> - <TextView - android:id="@+id/carrier" + <com.android.internal.widget.DigitalClock android:id="@+id/time" + android:layout_marginTop="56dip" + android:layout_marginBottom="8dip"> + + <!-- Because we can't have multi-tone fonts, we render two TextViews, one on + top of the other. Hence the redundant layout... --> + <TextView android:id="@+id/timeDisplayBackground" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_marginTop="20dip" android:singleLine="true" - android:ellipsize="marquee" - android:gravity="right|bottom" + android:ellipsize="none" + android:textSize="72sp" android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_marginBottom="6dip" + android:textColor="@color/lockscreen_clock_background" /> - <!-- "emergency calls only" shown when sim is missing or PUKd --> - <TextView - android:id="@+id/emergencyCallText" + <TextView android:id="@+id/timeDisplayForeground" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_marginTop="20dip" - android:text="@string/emergency_calls_only" - android:textAppearance="?android:attr/textAppearanceSmall" - android:textColor="@color/white" - /> - - <com.android.internal.widget.DigitalClock android:id="@+id/time" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/carrier" - android:layout_marginTop="56dip" - android:layout_marginBottom="8dip" - > - - <!-- Because we can't have multi-tone fonts, we render two TextViews, one on - top of the other. Hence the redundant layout... --> - <TextView android:id="@+id/timeDisplayBackground" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:singleLine="true" - android:ellipsize="none" - android:textSize="72sp" - android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_marginBottom="6dip" - android:textColor="@color/lockscreen_clock_background" - /> - - <TextView android:id="@+id/timeDisplayForeground" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:singleLine="true" - android:ellipsize="none" - android:textSize="72sp" - android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_marginBottom="6dip" - android:textColor="@color/lockscreen_clock_foreground" - android:layout_alignLeft="@id/timeDisplayBackground" - android:layout_alignTop="@id/timeDisplayBackground" - /> - - <TextView android:id="@+id/am_pm" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_toRightOf="@id/timeDisplayBackground" - android:layout_alignBaseline="@id/timeDisplayBackground" - android:singleLine="true" - android:ellipsize="none" - android:textSize="22sp" - android:layout_marginLeft="8dip" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textColor="@color/lockscreen_clock_am_pm" - /> - - </com.android.internal.widget.DigitalClock> - - <TextView - android:id="@+id/date" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/time" - android:layout_marginTop="6dip" + android:singleLine="true" + android:ellipsize="none" + android:textSize="72sp" android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_marginBottom="6dip" + android:textColor="@color/lockscreen_clock_foreground" + android:layout_alignLeft="@id/timeDisplayBackground" + android:layout_alignTop="@id/timeDisplayBackground" /> - <!-- TODO: Redo layout when we release on phones --> - <TextView - android:id="@+id/alarm_status" + <TextView android:id="@+id/am_pm" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_toRightOf="@id/timeDisplayBackground" + android:layout_alignBaseline="@id/timeDisplayBackground" + android:singleLine="true" + android:ellipsize="none" + android:textSize="22sp" + android:layout_marginLeft="8dip" android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="18sp" - android:drawablePadding="4dip" - android:layout_below="@id/date" - android:layout_marginTop="4dip" - android:layout_marginLeft="24dip" + android:textColor="@color/lockscreen_clock_am_pm" + android:visibility="gone" /> - <TextView - android:id="@+id/status1" + </com.android.internal.widget.DigitalClock> + + <TextView + android:id="@+id/date" + android:layout_below="@id/time" + android:layout_marginTop="6dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_gravity="left" + /> + + <TextView + android:id="@+id/alarm_status" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="18sp" + android:drawablePadding="4dip" + android:layout_marginTop="4dip" + android:layout_gravity="left" + /> + + <TextView + android:id="@+id/status1" + android:layout_marginTop="4dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:drawablePadding="4dip" + android:layout_gravity="left" + /> + + <TextView + android:id="@+id/status2" + android:layout_marginTop="4dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:drawablePadding="4dip" + android:layout_gravity="left" + /> + + <TextView + android:id="@+id/screenLocked" + android:textAppearance="?android:attr/textAppearanceMedium" + android:gravity="center" + android:layout_marginTop="4dip" + android:drawablePadding="4dip" + android:layout_gravity="left" + /> + + <Space android:height="20dip"/> + + <LinearLayout android:orientation="horizontal" > + + <TextView + android:id="@+id/carrier" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@id/alarm_status" - android:layout_marginTop="6dip" + android:layout_alignParentTop="true" + android:singleLine="true" + android:ellipsize="marquee" + android:layout_gravity="bottom|left" android:textAppearance="?android:attr/textAppearanceMedium" - android:drawablePadding="4dip" - /> + /> - <TextView - android:id="@+id/status2" + <Button + android:id="@+id/emergencyCallButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@id/status1" - android:layout_marginTop="6dip" - android:textAppearance="?android:attr/textAppearanceMedium" - android:drawablePadding="4dip" - /> + android:drawableLeft="@drawable/ic_emergency" + style="@style/Widget.Button.Transparent" + android:drawablePadding="8dip" + android:layout_marginRight="80dip" + android:visibility="gone" + /> + <!-- "emergency calls only" shown when sim is missing or PUKd --> <TextView - android:id="@+id/screenLocked" + android:id="@+id/emergencyCallText" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@id/status2" - android:textAppearance="?android:attr/textAppearanceMedium" - android:gravity="center" - android:layout_marginTop="12dip" - android:drawablePadding="4dip" - /> + android:layout_alignParentTop="true" + android:layout_marginTop="20dip" + android:text="@string/emergency_calls_only" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="@color/white" + /> + </LinearLayout> - </RelativeLayout> + <Space android:height="20dip"/> - <!-- right side --> + <!-- Column 1 --> + <Space android:width="20dip" android:layout_columnWeight="1" android:layout_rowSpan="10" /> + + <!-- Column 2 --> <com.android.internal.widget.multiwaveview.MultiWaveView android:id="@+id/unlock_widget" android:layout_width="300dip" android:layout_height="match_parent" + android:layout_rowSpan="10" android:targetDrawables="@array/lockscreen_targets_when_silent" android:handleDrawable="@drawable/ic_lockscreen_handle" @@ -178,21 +179,8 @@ android:vibrationDuration="20" android:topChevronDrawable="@drawable/ic_lockscreen_chevron_up" android:feedbackCount="3" - android:horizontalOffset="60dip" + android:horizontalOffset="0dip" android:verticalOffset="0dip" /> - <!-- emergency call button shown when sim is PUKd and tab_selector is - hidden --> - <Button - android:id="@+id/emergencyCallButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:drawableLeft="@drawable/ic_emergency" - style="@style/Widget.Button.Transparent" - android:drawablePadding="8dip" - android:layout_marginRight="80dip" - android:visibility="gone" - /> - -</LinearLayout> +</GridLayout> diff --git a/core/res/res/layout/keyguard_screen_unlock_landscape.xml b/core/res/res/layout/keyguard_screen_unlock_landscape.xml index c7b78c4473c6..d52bc57c8c59 100644 --- a/core/res/res/layout/keyguard_screen_unlock_landscape.xml +++ b/core/res/res/layout/keyguard_screen_unlock_landscape.xml @@ -21,198 +21,124 @@ the user how to unlock their device, or make an emergency call. This is the portrait layout. --> -<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient - xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="horizontal" +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/root" + android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="match_parent"> - - <!-- left side: instructions and emergency call button --> - <LinearLayout - android:orientation="vertical" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1.0" - android:layout_marginLeft="24dip" - android:gravity="left" - > - - <TextView - android:id="@+id/alarm_status" + android:layout_height="match_parent" + android:rowCount="9"> + + <!-- Column 0: Time, date and status --> + <com.android.internal.widget.DigitalClock android:id="@+id/time" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dip" + android:layout_marginBottom="12dip" + android:layout_gravity="right"> + + <!-- Because we can't have multi-tone fonts, we render two TextViews, one on + top of the other. Hence the redundant layout... --> + <TextView android:id="@+id/timeDisplayBackground" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:singleLine="true" + android:ellipsize="none" android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="18sp" - android:drawablePadding="4dip" - /> - <TextView - android:id="@+id/status1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="16dip" - android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@dimen/keyguard_pattern_unlock_clock_font_size" + android:layout_marginBottom="6dip" + android:textColor="@color/lockscreen_clock_background" /> - <TextView - android:id="@+id/carrier" + <TextView android:id="@+id/timeDisplayForeground" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="17sp" - android:drawablePadding="4dip" - android:layout_marginTop="32dip" android:singleLine="true" - android:ellipsize="marquee" - android:gravity="right|bottom" - /> - - <com.android.internal.widget.DigitalClock android:id="@+id/time" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_alignParentLeft="true" - android:layout_marginTop="8dip" - android:layout_marginBottom="8dip" - > - - <!-- Because we can't have multi-tone fonts, we render two TextViews, one on - top of the other. Hence the redundant layout... --> - <TextView android:id="@+id/timeDisplayBackground" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:singleLine="true" - android:ellipsize="none" - android:textSize="72sp" - android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_marginBottom="6dip" - android:textColor="@color/lockscreen_clock_background" - /> - - <TextView android:id="@+id/timeDisplayForeground" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:singleLine="true" - android:ellipsize="none" - android:textSize="72sp" - android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_marginBottom="6dip" - android:layout_alignLeft="@id/timeDisplayBackground" - android:layout_alignTop="@id/timeDisplayBackground" - android:textColor="@color/lockscreen_clock_foreground" - /> - - - - <TextView android:id="@+id/am_pm" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_toRightOf="@id/timeDisplayBackground" - android:layout_alignBaseline="@id/timeDisplayBackground" - android:singleLine="true" - android:ellipsize="none" - android:textSize="22sp" - android:layout_marginLeft="8dip" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textColor="@color/lockscreen_clock_am_pm" - /> - - </com.android.internal.widget.DigitalClock> - - <TextView - android:id="@+id/date" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/time" + android:ellipsize="none" android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@dimen/keyguard_pattern_unlock_clock_font_size" + android:layout_marginBottom="6dip" + android:layout_alignLeft="@id/timeDisplayBackground" + android:layout_alignTop="@id/timeDisplayBackground" + android:textColor="@color/lockscreen_clock_foreground" /> - <!-- used for instructions such as "draw pattern to unlock", the next alarm, and charging - status. --> - <LinearLayout - android:orientation="horizontal" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="8dip" - android:gravity="center" - > - <TextView - android:id="@+id/statusSep" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginLeft="5dip" - android:layout_marginRight="5dip" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="17sp" - /> - <TextView - android:id="@+id/status2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="17sp" - android:drawablePadding="4dip" - /> - </LinearLayout> - - <!-- fill space between header and button below --> - <View - android:layout_weight="1.0" - android:layout_width="match_parent" - android:layout_height="0dip" - /> - - <!-- footer --> - <FrameLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="16dip" - > - - <!-- option 1: a single emergency call button --> - <RelativeLayout android:id="@+id/footerNormal" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="left" - > - <Button android:id="@+id/emergencyCallAlone" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/lockscreen_emergency_call" - style="@style/Widget.Button.Transparent" - android:drawableLeft="@drawable/ic_emergency" - android:drawablePadding="8dip" - /> - </RelativeLayout> - - <!-- option 2: an emergency call button, and a 'forgot pattern?' button --> - <LinearLayout android:id="@+id/footerForgotPattern" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="left" - > - <Button android:id="@+id/forgotPattern" - android:layout_width="match_parent" - android:layout_height="wrap_content" - style="@style/Widget.Button.Transparent" - android:visibility="invisible" - /> - <Button android:id="@+id/emergencyCallTogether" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/lockscreen_emergency_call" - style="@style/Widget.Button.Transparent" - android:drawableLeft="@drawable/ic_emergency" - android:drawablePadding="8dip" - /> - </LinearLayout> - </FrameLayout> - </LinearLayout> - - <!-- right side: lock pattern --> + </com.android.internal.widget.DigitalClock> + + <TextView + android:id="@+id/date" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@dimen/keyguard_pattern_unlock_status_line_font_size" + android:layout_gravity="right" + /> + + <TextView + android:id="@+id/alarm_status" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@dimen/keyguard_pattern_unlock_status_line_font_size" + android:layout_gravity="right" + android:drawablePadding="4dip" + /> + + <TextView + android:id="@+id/status1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@dimen/keyguard_pattern_unlock_status_line_font_size" + android:layout_gravity="right" + /> + + <TextView + android:id="@+id/status2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@dimen/keyguard_pattern_unlock_status_line_font_size" + android:layout_gravity="right" + android:drawablePadding="4dip" + android:visibility="gone" + /> + + <Space android:layout_rowWeight="1" android:layout_columnWeight="1" /> + + <TextView android:id="@+id/carrier" + android:layout_gravity="right" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@dimen/keyguard_pattern_unlock_status_line_font_size" + android:singleLine="true" + android:ellipsize="marquee" + /> + + <Button android:id="@+id/emergencyCallButton" + android:layout_gravity="right" + style="@*android:style/Widget.Button.Transparent" + android:textSize="@dimen/keyguard_pattern_unlock_status_line_font_size" + android:text="@string/lockscreen_emergency_call" + android:drawableLeft="@*android:drawable/lockscreen_emergency_button" + android:drawablePadding="0dip" + /> + + <Button android:id="@+id/forgotPatternButton" + android:layout_gravity="right" + style="@*android:style/Widget.Button.Transparent" + android:textSize="@dimen/keyguard_pattern_unlock_status_line_font_size" + android:text="@*android:string/lockscreen_forgot_pattern_button_text" + android:drawableLeft="@*android:drawable/lockscreen_forgot_password_button" + android:drawablePadding="0dip" + /> + + <!-- Column 1: lock pattern --> <com.android.internal.widget.LockPatternView android:id="@+id/lockPattern" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - -</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginTop="8dip" + android:layout_marginRight="8dip" + android:layout_marginBottom="8dip" + android:layout_marginLeft="8dip" + android:layout_rowSpan="9"/> + +</GridLayout> diff --git a/core/res/res/layout/keyguard_screen_unlock_portrait.xml b/core/res/res/layout/keyguard_screen_unlock_portrait.xml index 15f2afb3c4d4..4ffa34055f69 100644 --- a/core/res/res/layout/keyguard_screen_unlock_portrait.xml +++ b/core/res/res/layout/keyguard_screen_unlock_portrait.xml @@ -20,213 +20,147 @@ <!-- This is the screen that shows the 9 circle unlock widget and instructs the user how to unlock their device, or make an emergency call. This is the portrait layout. --> -<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal"> - <RelativeLayout - android:layout_width="match_parent" + + <com.android.internal.widget.DigitalClock android:id="@+id/time" + android:layout_width="wrap_content" android:layout_height="wrap_content" - > - <TextView - android:id="@+id/carrier" + android:layout_marginBottom="18dip" + android:layout_marginRight="-4dip" + android:layout_gravity="right"> + + <!-- Because we can't have multi-tone fonts, we render two TextViews, one on + top of the other. Hence the redundant layout... --> + <TextView android:id="@*android:id/timeDisplayBackground" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_marginTop="6dip" - android:layout_alignParentRight="true" - android:layout_marginRight="8dip" - android:layout_toRightOf="@+id/time" android:singleLine="true" - android:ellipsize="marquee" - android:gravity="right|bottom" + android:ellipsize="none" + android:textSize="@*android:dimen/keyguard_pattern_unlock_clock_font_size" android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_marginBottom="6dip" + android:textColor="@*android:color/lockscreen_clock_background" /> - <com.android.internal.widget.DigitalClock android:id="@+id/time" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentTop="true" - android:layout_marginTop="15dip" - android:layout_marginLeft="20dip" - android:layout_marginBottom="8dip" - > - - <!-- Because we can't have multi-tone fonts, we render two TextViews, one on - top of the other. Hence the redundant layout... --> - <TextView android:id="@+id/timeDisplayBackground" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:singleLine="true" - android:ellipsize="none" - android:textSize="56sp" - android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_marginBottom="6dip" - android:textColor="@color/lockscreen_clock_background" - /> - - <TextView android:id="@+id/timeDisplayForeground" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:singleLine="true" - android:ellipsize="none" - android:textSize="56sp" - android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_marginBottom="6dip" - android:textColor="@color/lockscreen_clock_foreground" - /> - - <TextView android:id="@+id/am_pm" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_toRightOf="@id/timeDisplayBackground" - android:layout_alignBaseline="@id/timeDisplayBackground" - android:singleLine="true" - android:ellipsize="none" - android:textSize="18sp" - android:layout_marginLeft="4dip" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textColor="@color/lockscreen_clock_am_pm" - /> - - </com.android.internal.widget.DigitalClock> - - <TextView - android:id="@+id/date" + <TextView android:id="@*android:id/timeDisplayForeground" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@id/time" - android:layout_marginLeft="24dip" + android:singleLine="true" + android:ellipsize="none" + android:textSize="@*android:dimen/keyguard_pattern_unlock_clock_font_size" android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_marginBottom="6dip" + android:textColor="@color/lockscreen_clock_foreground" /> - </RelativeLayout> - - <View - android:id="@+id/divider" - android:layout_width="match_parent" - android:layout_height="1dip" - android:layout_marginTop="8dip" - android:layout_marginBottom="8dip" - android:background="@android:drawable/divider_horizontal_dark" - /> + </com.android.internal.widget.DigitalClock> - <!-- used for instructions such as "draw pattern to unlock", the next alarm, and charging - status. --> <LinearLayout android:orientation="horizontal" - android:layout_width="match_parent" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="0dip" - android:layout_marginLeft="12dip" - android:gravity="left" - > - <!-- TODO: Redo layout when we release on phones --> - <TextView - android:id="@+id/alarm_status" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="18sp" - android:drawablePadding="4dip" - /> - <TextView - android:id="@+id/status1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="18sp" - android:drawablePadding="4dip" - /> + android:layout_gravity="right"> + <TextView - android:id="@+id/statusSep" + android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="5dip" - android:layout_marginRight="5dip" android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="18sp" + android:textSize="@*android:dimen/keyguard_pattern_unlock_status_line_font_size" /> + <TextView - android:id="@+id/status2" + android:id="@+id/alarm_status" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentTop="true" + android:layout_marginLeft="16dip" android:textAppearance="?android:attr/textAppearanceMedium" - android:textSize="18sp" + android:textSize="@*android:dimen/keyguard_pattern_unlock_status_line_font_size" android:drawablePadding="4dip" /> + </LinearLayout> + + <TextView + android:id="@+id/status1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@*android:dimen/keyguard_pattern_unlock_status_line_font_size" + android:drawablePadding="4dip" + android:layout_gravity="right" + /> + + <TextView + android:id="@+id/status2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="@*android:dimen/keyguard_pattern_unlock_status_line_font_size" + android:drawablePadding="4dip" + android:layout_gravity="right" + android:visibility="gone" + /> + <com.android.internal.widget.LockPatternView android:id="@+id/lockPattern" - android:layout_width="match_parent" - android:layout_height="0dip" - android:layout_weight="1" - android:layout_marginTop="2dip" - android:aspect="@string/lock_pattern_view_aspect" - /> - - <!-- footer --> - <FrameLayout + android:layout_width="300dip" + android:layout_height="300dip" + android:layout_rowWeight="1" + android:layout_marginTop="8dip" + android:layout_marginRight="8dip" + android:layout_marginBottom="4dip" + android:layout_marginLeft="8dip" + /> + + <TextView + android:id="@+id/carrier" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:singleLine="true" + android:ellipsize="marquee" + android:textSize="@*android:dimen/keyguard_pattern_unlock_status_line_font_size" + android:textAppearance="?android:attr/textAppearanceMedium" + /> + + <!-- Footer: an emergency call button and an initially hidden "Forgot pattern" button --> + <LinearLayout + android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" - > - - <!-- option 1: a single emergency call button --> - <RelativeLayout android:id="@+id/footerNormal" - android:layout_width="match_parent" - android:layout_height="match_parent" - > - <Button android:id="@+id/emergencyCallAlone" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true" - android:text="@string/lockscreen_emergency_call" - style="@style/Widget.Button.Transparent" - android:drawableLeft="@drawable/ic_emergency" - android:drawablePadding="8dip" - /> - - </RelativeLayout> - - <!-- option 2: an emergency call button, and a 'forgot pattern?' button --> - <LinearLayout android:id="@+id/footerForgotPattern" - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center" - > - <Button android:id="@+id/emergencyCallTogether" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1.0" - android:layout_marginTop="4dip" - android:layout_marginBottom="4dip" - android:layout_marginLeft="4dip" - android:layout_marginRight="2dip" - android:text="@string/lockscreen_emergency_call" - style="@style/Widget.Button.Transparent" - android:drawableLeft="@drawable/ic_emergency" - android:drawablePadding="8dip" - /> - <Button android:id="@+id/forgotPattern" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1.0" - android:layout_marginTop="4dip" - android:layout_marginBottom="4dip" - android:layout_marginLeft="2dip" - android:layout_marginRight="4dip" - style="@style/Widget.Button.Transparent" - android:visibility="invisible" - /> - </LinearLayout> - - </FrameLayout> - -</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient> + android:layout_gravity="center"> + + <Button android:id="@+id/emergencyCallButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + style="@style/Widget.Button.Transparent" + android:textSize="@dimen/keyguard_pattern_unlock_status_line_font_size" + android:text="@string/lockscreen_emergency_call" + android:drawableLeft="@drawable/lockscreen_emergency_button" + android:drawablePadding="0dip" + /> + + <Button android:id="@+id/forgotPatternButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + style="@style/Widget.Button.Transparent" + android:textSize="@dimen/keyguard_pattern_unlock_status_line_font_size" + android:text="@string/lockscreen_forgot_pattern_button_text" + android:drawableLeft="@drawable/lockscreen_forgot_password_button" + android:drawablePadding="0dip" + /> + + </LinearLayout> + +</GridLayout> diff --git a/core/res/res/values-land/dimens.xml b/core/res/res/values-land/dimens.xml index dbaad13f4019..b8ce9b4bb95a 100644 --- a/core/res/res/values-land/dimens.xml +++ b/core/res/res/values-land/dimens.xml @@ -32,4 +32,7 @@ <!-- Default height of an action bar. --> <dimen name="action_bar_default_height">40dip</dimen> + <!-- Size of clock font in LockScreen. --> + <dimen name="keyguard_pattern_unlock_clock_font_size">80sp</dimen> + </resources> diff --git a/core/res/res/values-sw600dp/dimens.xml b/core/res/res/values-sw600dp/dimens.xml index df1597cdcc27..150b6d4c137a 100644 --- a/core/res/res/values-sw600dp/dimens.xml +++ b/core/res/res/values-sw600dp/dimens.xml @@ -24,5 +24,12 @@ <dimen name="status_bar_icon_size">32dip</dimen> <!-- Size of the giant number (unread count) in the notifications --> <dimen name="status_bar_content_number_size">48sp</dimen> + + <!-- Size of clock font in LockScreen. --> + <dimen name="keyguard_pattern_unlock_clock_font_size">98sp</dimen> + + <!-- Size of status line font in LockScreen. --> + <dimen name="keyguard_pattern_unlock_status_line_font_size">14sp</dimen> + </resources> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 4deb8caecec2..52b00c6af8eb 100755 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -636,6 +636,7 @@ <!-- Set to true if the RSSI should always display CDMA signal strength even on EVDO --> <bool name="config_alwaysUseCdmaRssi">false</bool> + <!-- If this value is true, duplicate Source/Destination port fields in WDP header of some carriers OMADM wap push are supported. ex: MSGTYPE-TotalSegments-CurrentSegment @@ -648,4 +649,9 @@ with @string/status_bar_notification_info_overflow when shown in the UI. --> <integer name="status_bar_notification_info_maxnum">999</integer> + + <!-- Path to an ISO image to be shared with via USB mass storage. + This is intended to allow packaging drivers or tools for installation on a PC. --> + <string translatable="false" name="config_isoImagePath"></string> + </resources> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 0725c2fcf64c..20cb85273a8f 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -119,4 +119,14 @@ <dimen name="action_bar_default_height">48dip</dimen> <!-- Vertical padding around action bar icons. --> <dimen name="action_bar_icon_vertical_padding">4dip</dimen> + + <!-- Size of clock font in LockScreen. --> + <dimen name="keyguard_pattern_unlock_clock_font_size">80sp</dimen> + + <!-- Size of status line font in LockScreen. --> + <dimen name="keyguard_pattern_unlock_status_line_font_size">14sp</dimen> + + <!-- Size of right margin in LockScreen --> + <dimen name="keyguard_pattern_unlock_status_line_font_right_margin">20dip</dimen> + </resources> diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index 596781e31aa4..e64d8ac48d56 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -74,7 +74,7 @@ static const GLsizei gMeshCount = 4; struct CacheLogger { CacheLogger() { - LOGD("Creating OpenGL renderer caches"); + INIT_LOGD("Creating OpenGL renderer caches"); } }; // struct CacheLogger diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index 146e7894aa73..77e63d70f474 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -326,12 +326,17 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) { return false; } + SkAutoLockPixels alp(*bitmap); + GLuint texture; GLuint previousFbo; GLenum format; GLenum type; + GLenum error = GL_NO_ERROR; + bool status = false; + switch (bitmap->config()) { case SkBitmap::kA8_Config: format = GL_ALPHA; @@ -352,10 +357,18 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) { break; } + float alpha = layer->alpha; + SkXfermode::Mode mode = layer->mode; + + layer->mode = SkXfermode::kSrc_Mode; + layer->alpha = 255; + layer->fbo = fbo; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &previousFbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glGenTextures(1, &texture); + if ((error = glGetError()) != GL_NO_ERROR) goto error; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); @@ -368,39 +381,48 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) { glTexImage2D(GL_TEXTURE_2D, 0, format, bitmap->width(), bitmap->height(), 0, format, type, NULL); + if ((error = glGetError()) != GL_NO_ERROR) goto error; + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); + if ((error = glGetError()) != GL_NO_ERROR) goto error; - glBindTexture(GL_TEXTURE_2D, layer->texture); + { + LayerRenderer renderer(layer); + renderer.setViewport(bitmap->width(), bitmap->height()); + renderer.OpenGLRenderer::prepareDirty(0.0f, 0.0f, + bitmap->width(), bitmap->height(), !layer->blend); + if ((error = glGetError()) != GL_NO_ERROR) goto error; - float alpha = layer->alpha; - SkXfermode::Mode mode = layer->mode; + { + Rect bounds; + bounds.set(0.0f, 0.0f, bitmap->width(), bitmap->height()); + renderer.drawTextureLayer(layer, bounds); - layer->mode = SkXfermode::kSrc_Mode; - layer->alpha = 255; - layer->fbo = fbo; + glReadPixels(0, 0, bitmap->width(), bitmap->height(), format, + type, bitmap->getPixels()); - LayerRenderer renderer(layer); - renderer.setViewport(bitmap->width(), bitmap->height()); - renderer.OpenGLRenderer::prepareDirty(0.0f, 0.0f, - bitmap->width(), bitmap->height(), !layer->blend); + if ((error = glGetError()) != GL_NO_ERROR) goto error; + } - Rect bounds; - bounds.set(0.0f, 0.0f, bitmap->width(), bitmap->height()); - renderer.drawTextureLayer(layer, bounds); + status = true; + } - SkAutoLockPixels alp(*bitmap); - glReadPixels(0, 0, bitmap->width(), bitmap->height(), format, type, bitmap->getPixels()); +error: +#if DEBUG_OPENGL + if (error != GL_NO_ERROR) { + LOGD("GL error while copying layer into bitmap = 0x%x", error); + } +#endif glBindFramebuffer(GL_FRAMEBUFFER, previousFbo); - layer->mode = mode; layer->alpha = alpha; layer->fbo = 0; glDeleteTextures(1, &texture); caches.fboCache.put(fbo); - return true; + return status; } return false; } diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 5343a059ec26..88774c6dff47 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -151,7 +151,6 @@ void OpenGLRenderer::prepareDirty(float left, float top, float right, float bott mSaveCount = 1; glViewport(0, 0, mWidth, mHeight); - glDisable(GL_DITHER); glEnable(GL_SCISSOR_TEST); diff --git a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java index a6854973bab1..cd79b60f8b96 100644 --- a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java +++ b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java @@ -23,6 +23,7 @@ import android.os.SystemClock; import android.security.KeyStore; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.MotionEvent; import android.widget.Button; @@ -73,12 +74,8 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient private boolean mEnableFallback; private StatusView mStatusView; - private LockPatternView mLockPatternView; - private ViewGroup mFooterNormal; - private ViewGroup mFooterForgotPattern; - /** * Keeps track of the last time we poked the wake lock during dispatching * of the touch event, initalized to something gauranteed to make us @@ -96,9 +93,20 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient } }; + private final OnClickListener mEmergencyClick = new OnClickListener() { + public void onClick(View v) { + mCallback.takeEmergencyCallAction(); + } + }; + + private final OnClickListener mForgotPatternClick = new OnClickListener() { + public void onClick(View v) { + mCallback.forgotPattern(true); + } + }; + private Button mForgotPatternButton; - private Button mEmergencyAlone; - private Button mEmergencyTogether; + private Button mEmergencyButton; private int mCreationOrientation; enum FooterMode { @@ -107,23 +115,27 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient VerifyUnlocked } + private void hideForgotPatternButton() { + mForgotPatternButton.setVisibility(View.GONE); + } + + private void showForgotPatternButton() { + mForgotPatternButton.setVisibility(View.VISIBLE); + } + private void updateFooter(FooterMode mode) { switch (mode) { case Normal: - Log.d(TAG, "mode normal"); - mFooterNormal.setVisibility(View.VISIBLE); - mFooterForgotPattern.setVisibility(View.GONE); + if (DEBUG) Log.d(TAG, "mode normal"); + hideForgotPatternButton(); break; case ForgotLockPattern: - Log.d(TAG, "mode ForgotLockPattern"); - mFooterNormal.setVisibility(View.GONE); - mFooterForgotPattern.setVisibility(View.VISIBLE); - mForgotPatternButton.setVisibility(View.VISIBLE); + if (DEBUG) Log.d(TAG, "mode ForgotLockPattern"); + showForgotPatternButton(); break; case VerifyUnlocked: - Log.d(TAG, "mode VerifyUnlocked"); - mFooterNormal.setVisibility(View.GONE); - mFooterForgotPattern.setVisibility(View.GONE); + if (DEBUG) Log.d(TAG, "mode VerifyUnlocked"); + hideForgotPatternButton(); } } @@ -176,32 +188,16 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern); - mFooterNormal = (ViewGroup) findViewById(R.id.footerNormal); - mFooterForgotPattern = (ViewGroup) findViewById(R.id.footerForgotPattern); - // emergency call buttons - final OnClickListener emergencyClick = new OnClickListener() { - public void onClick(View v) { - mCallback.takeEmergencyCallAction(); - } - }; - - mEmergencyAlone = (Button) findViewById(R.id.emergencyCallAlone); - mEmergencyAlone.setFocusable(false); // touch only! - mEmergencyAlone.setOnClickListener(emergencyClick); - mEmergencyTogether = (Button) findViewById(R.id.emergencyCallTogether); - mEmergencyTogether.setFocusable(false); - mEmergencyTogether.setOnClickListener(emergencyClick); + mEmergencyButton = (Button) findViewById(R.id.emergencyCallButton); + mEmergencyButton.setFocusable(false); // touch only! + mEmergencyButton.setOnClickListener(mEmergencyClick); + refreshEmergencyButtonText(); - mForgotPatternButton = (Button) findViewById(R.id.forgotPattern); + mForgotPatternButton = (Button) findViewById(R.id.forgotPatternButton); mForgotPatternButton.setText(R.string.lockscreen_forgot_pattern_button_text); - mForgotPatternButton.setOnClickListener(new OnClickListener() { - - public void onClick(View v) { - mCallback.forgotPattern(true); - } - }); + mForgotPatternButton.setOnClickListener(mForgotPatternClick); // make it so unhandled touch events within the unlock screen go to the // lock pattern view. @@ -232,8 +228,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient } private void refreshEmergencyButtonText() { - mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyAlone); - mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyTogether); + mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyButton); } public void setEnableFallback(boolean state) { @@ -338,8 +333,11 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient mLockPatternView.clearPattern(); // show "forgot pattern?" button if we have an alternate authentication method - mForgotPatternButton.setVisibility(mCallback.doesFallbackUnlockScreenExist() - ? View.VISIBLE : View.INVISIBLE); + if (mCallback.doesFallbackUnlockScreenExist()) { + showForgotPatternButton(); + } else { + hideForgotPatternButton(); + } // if the user is currently locked out, enforce it. long deadline = mLockPatternUtils.getLockoutAttemptDeadline(); diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 07855d960a4d..aa3dfa6201c0 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -19,7 +19,7 @@ package com.android.server; import static android.Manifest.permission.MANAGE_NETWORK_POLICY; import static android.net.ConnectivityManager.isNetworkTypeValid; import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL; -import static android.net.NetworkPolicyManager.RULE_REJECT_PAID; +import static android.net.NetworkPolicyManager.RULE_REJECT_METERED; import android.bluetooth.BluetoothTetheringDataTracker; import android.content.ContentResolver; @@ -71,6 +71,7 @@ import com.android.server.connectivity.Tethering; import com.android.server.connectivity.Vpn; import com.google.android.collect.Lists; +import com.google.android.collect.Sets; import java.io.FileDescriptor; import java.io.IOException; @@ -78,8 +79,10 @@ import java.io.PrintWriter; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.GregorianCalendar; +import java.util.HashSet; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -108,8 +111,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { private Vpn mVpn; + /** Lock around {@link #mUidRules} and {@link #mMeteredIfaces}. */ + private Object mRulesLock = new Object(); /** Currently active network rules by UID. */ private SparseIntArray mUidRules = new SparseIntArray(); + /** Set of ifaces that are costly. */ + private HashSet<String> mMeteredIfaces = Sets.newHashSet(); /** * Sometimes we want to refer to the individual network state @@ -570,31 +577,35 @@ public class ConnectivityService extends IConnectivityManager.Stub { } /** - * Check if UID is blocked from using the given {@link NetworkInfo}. + * Check if UID should be blocked from using the network represented by the + * given {@link NetworkStateTracker}. */ - private boolean isNetworkBlocked(NetworkInfo info, int uid) { - synchronized (mUidRules) { - // TODO: expand definition of "paid" network to cover tethered or - // paid hotspot use cases. - final boolean networkIsPaid = info.getType() != ConnectivityManager.TYPE_WIFI; - final int uidRules = mUidRules.get(uid, RULE_ALLOW_ALL); + private boolean isNetworkBlocked(NetworkStateTracker tracker, int uid) { + final String iface = tracker.getLinkProperties().getInterfaceName(); - if (networkIsPaid && (uidRules & RULE_REJECT_PAID) != 0) { - return true; - } + final boolean networkCostly; + final int uidRules; + synchronized (mRulesLock) { + networkCostly = mMeteredIfaces.contains(iface); + uidRules = mUidRules.get(uid, RULE_ALLOW_ALL); + } - // no restrictive rules; network is visible - return false; + if (networkCostly && (uidRules & RULE_REJECT_METERED) != 0) { + return true; } + + // no restrictive rules; network is visible + return false; } /** - * Return a filtered version of the given {@link NetworkInfo}, potentially - * marked {@link DetailedState#BLOCKED} based on - * {@link #isNetworkBlocked(NetworkInfo, int)}. + * Return a filtered {@link NetworkInfo}, potentially marked + * {@link DetailedState#BLOCKED} based on + * {@link #isNetworkBlocked(NetworkStateTracker, int)}. */ - private NetworkInfo filterNetworkInfo(NetworkInfo info, int uid) { - if (isNetworkBlocked(info, uid)) { + private NetworkInfo getFilteredNetworkInfo(NetworkStateTracker tracker, int uid) { + NetworkInfo info = tracker.getNetworkInfo(); + if (isNetworkBlocked(tracker, uid)) { // network is blocked; clone and override state info = new NetworkInfo(info); info.setDetailedState(DetailedState.BLOCKED, null, null); @@ -634,7 +645,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (isNetworkTypeValid(networkType)) { final NetworkStateTracker tracker = mNetTrackers[networkType]; if (tracker != null) { - info = filterNetworkInfo(tracker.getNetworkInfo(), uid); + info = getFilteredNetworkInfo(tracker, uid); } } return info; @@ -645,10 +656,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { enforceAccessPermission(); final int uid = Binder.getCallingUid(); final ArrayList<NetworkInfo> result = Lists.newArrayList(); - synchronized (mUidRules) { + synchronized (mRulesLock) { for (NetworkStateTracker tracker : mNetTrackers) { if (tracker != null) { - result.add(filterNetworkInfo(tracker.getNetworkInfo(), uid)); + result.add(getFilteredNetworkInfo(tracker, uid)); } } } @@ -685,10 +696,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { enforceAccessPermission(); final int uid = Binder.getCallingUid(); final ArrayList<NetworkState> result = Lists.newArrayList(); - synchronized (mUidRules) { + synchronized (mRulesLock) { for (NetworkStateTracker tracker : mNetTrackers) { if (tracker != null) { - final NetworkInfo info = filterNetworkInfo(tracker.getNetworkInfo(), uid); + final NetworkInfo info = getFilteredNetworkInfo(tracker, uid); result.add(new NetworkState( info, tracker.getLinkProperties(), tracker.getLinkCapabilities())); } @@ -1139,15 +1150,15 @@ public class ConnectivityService extends IConnectivityManager.Stub { private INetworkPolicyListener mPolicyListener = new INetworkPolicyListener.Stub() { @Override - public void onRulesChanged(int uid, int uidRules) { + public void onUidRulesChanged(int uid, int uidRules) { // only someone like NPMS should only be calling us mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG); if (LOGD_RULES) { - Slog.d(TAG, "onRulesChanged(uid=" + uid + ", uidRules=" + uidRules + ")"); + Slog.d(TAG, "onUidRulesChanged(uid=" + uid + ", uidRules=" + uidRules + ")"); } - synchronized (mUidRules) { + synchronized (mRulesLock) { // skip update when we've already applied rules final int oldRules = mUidRules.get(uid, RULE_ALLOW_ALL); if (oldRules == uidRules) return; @@ -1158,6 +1169,24 @@ public class ConnectivityService extends IConnectivityManager.Stub { // TODO: dispatch into NMS to push rules towards kernel module // TODO: notify UID when it has requested targeted updates } + + @Override + public void onMeteredIfacesChanged(String[] meteredIfaces) { + // only someone like NPMS should only be calling us + mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG); + + if (LOGD_RULES) { + Slog.d(TAG, + "onMeteredIfacesChanged(ifaces=" + Arrays.toString(meteredIfaces) + ")"); + } + + synchronized (mRulesLock) { + mMeteredIfaces.clear(); + for (String iface : meteredIfaces) { + mMeteredIfaces.add(iface); + } + } + } }; /** diff --git a/services/java/com/android/server/connectivity/Vpn.java b/services/java/com/android/server/connectivity/Vpn.java index 035a66792bb4..47813f8f7b69 100644 --- a/services/java/com/android/server/connectivity/Vpn.java +++ b/services/java/com/android/server/connectivity/Vpn.java @@ -102,14 +102,22 @@ public class Vpn extends INetworkManagementEventObserver.Stub { /** * Protect a socket from routing changes by binding it to the given - * interface. The socket is NOT closed by this method. + * interface. The socket IS closed by this method. * * @param socket The socket to be bound. * @param name The name of the interface. */ public void protect(ParcelFileDescriptor socket, String name) { - mContext.enforceCallingPermission(VPN, "protect"); - nativeProtect(socket.getFd(), name); + try { + mContext.enforceCallingPermission(VPN, "protect"); + nativeProtect(socket.getFd(), name); + } finally { + try { + socket.close(); + } catch (Exception e) { + // ignore + } + } } /** diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java index 9cbe82d263eb..43f3c63cdc07 100644 --- a/services/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java @@ -29,9 +29,9 @@ import static android.net.NetworkPolicyManager.ACTION_DATA_USAGE_LIMIT; import static android.net.NetworkPolicyManager.ACTION_DATA_USAGE_WARNING; import static android.net.NetworkPolicyManager.EXTRA_NETWORK_TEMPLATE; import static android.net.NetworkPolicyManager.POLICY_NONE; -import static android.net.NetworkPolicyManager.POLICY_REJECT_PAID_BACKGROUND; +import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND; import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL; -import static android.net.NetworkPolicyManager.RULE_REJECT_PAID; +import static android.net.NetworkPolicyManager.RULE_REJECT_METERED; import static android.net.NetworkPolicyManager.computeLastCycleBoundary; import static android.net.NetworkPolicyManager.dumpPolicy; import static android.net.NetworkPolicyManager.dumpRules; @@ -87,6 +87,7 @@ import com.android.internal.util.FastXmlSerializer; import com.android.internal.util.Objects; import com.google.android.collect.Lists; import com.google.android.collect.Maps; +import com.google.android.collect.Sets; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -103,6 +104,7 @@ import java.net.ProtocolException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import libcore.io.IoUtils; @@ -164,6 +166,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { /** Current derived network rules for each UID. */ private SparseIntArray mUidRules = new SparseIntArray(); + /** Set of ifaces that are metered. */ + private HashSet<String> mMeteredIfaces = Sets.newHashSet(); + /** Foreground at both UID and PID granularity. */ private SparseBooleanArray mUidForeground = new SparseBooleanArray(); private SparseArray<SparseBooleanArray> mUidPidForeground = new SparseArray< @@ -536,6 +541,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { final long currentTime = mTime.hasCache() ? mTime.currentTimeMillis() : System.currentTimeMillis(); + mMeteredIfaces.clear(); + // apply each policy that we found ifaces for; compute remaining data // based on current cycle and historical stats, and push to kernel. for (NetworkPolicy policy : rules.keySet()) { @@ -566,8 +573,27 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { // remaining "quota" is based on usage in current cycle final long quota = Math.max(0, policy.limitBytes - total); //kernelSetIfacesQuota(ifaces, quota); + + for (String iface : ifaces) { + mMeteredIfaces.add(iface); + } } } + + // dispatch changed rule to existing listeners + // TODO: dispatch outside of holding lock + final String[] meteredIfaces = mMeteredIfaces.toArray(new String[mMeteredIfaces.size()]); + final int length = mListeners.beginBroadcast(); + for (int i = 0; i < length; i++) { + final INetworkPolicyListener listener = mListeners.getBroadcastItem(i); + if (listener != null) { + try { + listener.onMeteredIfacesChanged(meteredIfaces); + } catch (RemoteException e) { + } + } + } + mListeners.finishBroadcast(); } /** @@ -754,17 +780,29 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { synchronized (mRulesLock) { // dispatch any existing rules to new listeners + // TODO: dispatch outside of holding lock final int size = mUidRules.size(); for (int i = 0; i < size; i++) { final int uid = mUidRules.keyAt(i); final int uidRules = mUidRules.valueAt(i); if (uidRules != RULE_ALLOW_ALL) { try { - listener.onRulesChanged(uid, uidRules); + listener.onUidRulesChanged(uid, uidRules); } catch (RemoteException e) { } } } + + // dispatch any metered ifaces to new listeners + // TODO: dispatch outside of holding lock + if (mMeteredIfaces.size() > 0) { + final String[] meteredIfaces = mMeteredIfaces.toArray( + new String[mMeteredIfaces.size()]); + try { + listener.onMeteredIfacesChanged(meteredIfaces); + } catch (RemoteException e) { + } + } } } @@ -921,9 +959,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { // derive active rules based on policy and active state int uidRules = RULE_ALLOW_ALL; - if (!uidForeground && (uidPolicy & POLICY_REJECT_PAID_BACKGROUND) != 0) { - // uid in background, and policy says to block paid data - uidRules = RULE_REJECT_PAID; + if (!uidForeground && (uidPolicy & POLICY_REJECT_METERED_BACKGROUND) != 0) { + // uid in background, and policy says to block metered data + uidRules = RULE_REJECT_METERED; } // TODO: only dispatch when rules actually change @@ -931,16 +969,17 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { // record rule locally to dispatch to new listeners mUidRules.put(uid, uidRules); - final boolean rejectPaid = (uidRules & RULE_REJECT_PAID) != 0; + final boolean rejectMetered = (uidRules & RULE_REJECT_METERED) != 0; //kernelSetUidRejectPaid(uid, rejectPaid); // dispatch changed rule to existing listeners + // TODO: dispatch outside of holding lock final int length = mListeners.beginBroadcast(); for (int i = 0; i < length; i++) { final INetworkPolicyListener listener = mListeners.getBroadcastItem(i); if (listener != null) { try { - listener.onRulesChanged(uid, uidRules); + listener.onUidRulesChanged(uid, uidRules); } catch (RemoteException e) { } } diff --git a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java index edccf6cbce1f..5cb1763f21f4 100644 --- a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java @@ -19,13 +19,14 @@ package com.android.server; import static android.net.ConnectivityManager.CONNECTIVITY_ACTION; import static android.net.ConnectivityManager.TYPE_WIFI; import static android.net.NetworkPolicyManager.POLICY_NONE; -import static android.net.NetworkPolicyManager.POLICY_REJECT_PAID_BACKGROUND; +import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND; import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL; -import static android.net.NetworkPolicyManager.RULE_REJECT_PAID; +import static android.net.NetworkPolicyManager.RULE_REJECT_METERED; import static android.net.NetworkPolicyManager.computeLastCycleBoundary; import static android.net.NetworkStats.UID_ALL; import static android.net.TrafficStats.TEMPLATE_WIFI; import static org.easymock.EasyMock.anyInt; +import static org.easymock.EasyMock.aryEq; import static org.easymock.EasyMock.capture; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.eq; @@ -182,7 +183,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { final Future<Intent> backgroundChanged = mServiceContext.nextBroadcastIntent( ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED); - mService.setUidPolicy(UID_A, POLICY_REJECT_PAID_BACKGROUND); + mService.setUidPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND); backgroundChanged.get(); } @@ -225,12 +226,12 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { expectRulesChanged(UID_A, RULE_ALLOW_ALL); replay(); mProcessObserver.onForegroundActivitiesChanged(PID_1, UID_A, true); - mService.setUidPolicy(UID_A, POLICY_REJECT_PAID_BACKGROUND); + mService.setUidPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND); verifyAndReset(); // now turn screen off and verify REJECT rule expect(mPowerManager.isScreenOn()).andReturn(false).atLeastOnce(); - expectRulesChanged(UID_A, RULE_REJECT_PAID); + expectRulesChanged(UID_A, RULE_REJECT_METERED); replay(); mServiceContext.sendBroadcast(new Intent(Intent.ACTION_SCREEN_OFF)); verifyAndReset(); @@ -260,9 +261,9 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { public void testPolicyReject() throws Exception { // POLICY_REJECT should RULE_ALLOW in background - expectRulesChanged(UID_A, RULE_REJECT_PAID); + expectRulesChanged(UID_A, RULE_REJECT_METERED); replay(); - mService.setUidPolicy(UID_A, POLICY_REJECT_PAID_BACKGROUND); + mService.setUidPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND); verifyAndReset(); // POLICY_REJECT should RULE_ALLOW in foreground @@ -272,7 +273,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { verifyAndReset(); // POLICY_REJECT should RULE_REJECT in background - expectRulesChanged(UID_A, RULE_REJECT_PAID); + expectRulesChanged(UID_A, RULE_REJECT_METERED); replay(); mProcessObserver.onForegroundActivitiesChanged(PID_1, UID_A, false); verifyAndReset(); @@ -287,9 +288,9 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { verifyAndReset(); // adding POLICY_REJECT should cause RULE_REJECT - expectRulesChanged(UID_A, RULE_REJECT_PAID); + expectRulesChanged(UID_A, RULE_REJECT_METERED); replay(); - mService.setUidPolicy(UID_A, POLICY_REJECT_PAID_BACKGROUND); + mService.setUidPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND); verifyAndReset(); // removing POLICY_REJECT should return us to RULE_ALLOW @@ -353,6 +354,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { state = new NetworkState[] { buildWifi() }; expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce(); expectTime(TIME_MAR_10 + elapsedRealtime); + expectMeteredIfacesChanged(); replay(); mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION)); @@ -373,6 +375,7 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { // TODO: write up NetworkManagementService mock expectClearNotifications(); + expectMeteredIfacesChanged(TEST_IFACE); replay(); setNetworkPolicies(new NetworkPolicy(TEMPLATE_WIFI, null, CYCLE_DAY, 1024L, 2048L)); @@ -411,7 +414,12 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase { } private void expectRulesChanged(int uid, int policy) throws Exception { - mPolicyListener.onRulesChanged(eq(uid), eq(policy)); + mPolicyListener.onUidRulesChanged(eq(uid), eq(policy)); + expectLastCall().atLeastOnce(); + } + + private void expectMeteredIfacesChanged(String... ifaces) throws Exception { + mPolicyListener.onMeteredIfacesChanged(aryEq(ifaces)); expectLastCall().atLeastOnce(); } diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index d5dcd4eecd4c..c650021e7d35 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -31,6 +31,15 @@ android:hardwareAccelerated="true"> <activity + android:name="GetBitmapActivity" + android:label="_GetBitmap"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <activity android:name="SmallCircleActivity" android:label="_SmallCircle"> <intent-filter> diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java new file mode 100644 index 000000000000..2e23aaa7b675 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2011 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. + */ + +package com.android.test.hwui; + +import android.app.Activity; +import android.graphics.Bitmap; +import android.graphics.SurfaceTexture; +import android.hardware.Camera; +import android.os.Bundle; +import android.os.Environment; +import android.view.Gravity; +import android.view.TextureView; +import android.view.View; +import android.widget.Button; +import android.widget.FrameLayout; + +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +@SuppressWarnings({"UnusedDeclaration"}) +public class GetBitmapActivity extends Activity implements TextureView.SurfaceTextureListener { + private Camera mCamera; + private TextureView mTextureView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + FrameLayout content = new FrameLayout(this); + + mTextureView = new TextureView(this); + mTextureView.setSurfaceTextureListener(this); + + Button button = new Button(this); + button.setText("Copy bitmap to /sdcard/textureview.png"); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Bitmap b = mTextureView.getBitmap(); + try { + FileOutputStream out = new FileOutputStream( + Environment.getExternalStorageDirectory() + "/textureview.png"); + try { + b.compress(Bitmap.CompressFormat.PNG, 100, out); + } finally { + try { + out.close(); + } catch (IOException e) { + // Ignore + } + } + } catch (FileNotFoundException e) { + // Ignore + } + } + }); + + content.addView(mTextureView, new FrameLayout.LayoutParams(500, 400, Gravity.CENTER)); + content.addView(button, new FrameLayout.LayoutParams( + FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, + Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)); + setContentView(content); + } + + @Override + public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { + mCamera = Camera.open(); + + try { + mCamera.setPreviewTexture(surface); + } catch (IOException t) { + android.util.Log.e("TextureView", "Cannot set preview texture target!", t); + } + + mCamera.startPreview(); + } + + @Override + public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { + // Ignored, the Camera does all the work for us + } + + @Override + public void onSurfaceTextureDestroyed(SurfaceTexture surface) { + mCamera.stopPreview(); + mCamera.release(); + } +} |