Merge "Fix rectangle AA offset calculation" into jb-mr1-dev
diff --git a/api/current.txt b/api/current.txt
index 91e5ddd..ea26c9a 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4476,6 +4476,7 @@
   public class AppWidgetProviderInfo implements android.os.Parcelable {
     ctor public AppWidgetProviderInfo();
     ctor public AppWidgetProviderInfo(android.os.Parcel);
+    method public android.appwidget.AppWidgetProviderInfo clone();
     method public int describeContents();
     method public void writeToParcel(android.os.Parcel, int);
     field public static final android.os.Parcelable.Creator CREATOR;
diff --git a/core/java/android/app/backup/FullBackup.java b/core/java/android/app/backup/FullBackup.java
index d7f1c9f..f859599 100644
--- a/core/java/android/app/backup/FullBackup.java
+++ b/core/java/android/app/backup/FullBackup.java
@@ -64,7 +64,9 @@
 
     /**
      * Copy data from a socket to the given File location on permanent storage.  The
-     * modification time and access mode of the resulting file will be set if desired.
+     * modification time and access mode of the resulting file will be set if desired,
+     * although group/all rwx modes will be stripped: the restored file will not be
+     * accessible from outside the target application even if the original file was.
      * If the {@code type} parameter indicates that the result should be a directory,
      * the socket parameter may be {@code null}; even if it is valid, no data will be
      * read from it in this case.
@@ -79,8 +81,9 @@
      * @param type Must be either {@link BackupAgent#TYPE_FILE} for ordinary file data
      *    or {@link BackupAgent#TYPE_DIRECTORY} for a directory.
      * @param mode Unix-style file mode (as used by the chmod(2) syscall) to be set on
-     *    the output file or directory.  If this parameter is negative then neither
-     *    the mode nor the mtime parameters will be used.
+     *    the output file or directory.  group/all rwx modes are stripped even if set
+     *    in this parameter.  If this parameter is negative then neither
+     *    the mode nor the mtime values will be applied to the restored file.
      * @param mtime A timestamp in the standard Unix epoch that will be imposed as the
      *    last modification time of the output file.  if the {@code mode} parameter is
      *    negative then this parameter will be ignored.
@@ -105,8 +108,6 @@
                     if (!parent.exists()) {
                         // in practice this will only be for the default semantic directories,
                         // and using the default mode for those is appropriate.
-                        // TODO: support the edge case of apps that have adjusted the
-                        //       permissions on these core directories
                         parent.mkdirs();
                     }
                     out = new FileOutputStream(outFile);
@@ -146,6 +147,8 @@
         // Now twiddle the state to match the backup, assuming all went well
         if (mode >= 0 && outFile != null) {
             try {
+                // explicitly prevent emplacement of files accessible by outside apps
+                mode &= 0700;
                 Libcore.os.chmod(outFile.getPath(), (int)mode);
             } catch (ErrnoException e) {
                 e.rethrowAsIOException();
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
index 185fb5a..cb61a71 100644
--- a/core/java/android/appwidget/AppWidgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -21,6 +21,7 @@
 
 import android.app.ActivityThread;
 import android.content.Context;
+import android.os.Binder;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Looper;
@@ -57,6 +58,9 @@
 
     class Callbacks extends IAppWidgetHost.Stub {
         public void updateAppWidget(int appWidgetId, RemoteViews views) {
+            if (isLocalBinder() && views != null) {
+                views = views.clone();
+            }
             Message msg = mHandler.obtainMessage(HANDLE_UPDATE);
             msg.arg1 = appWidgetId;
             msg.obj = views;
@@ -64,6 +68,9 @@
         }
 
         public void providerChanged(int appWidgetId, AppWidgetProviderInfo info) {
+            if (isLocalBinder() && info != null) {
+                info = info.clone();
+            }
             Message msg = mHandler.obtainMessage(HANDLE_PROVIDER_CHANGED);
             msg.arg1 = appWidgetId;
             msg.obj = info;
@@ -225,6 +232,10 @@
         throw new SecurityException("Disallowed call for uid " + uid);
     }
 
+    private boolean isLocalBinder() {
+        return Process.myPid() == Binder.getCallingPid();
+    }
+
     /**
      * Stop listening to changes for this AppWidget.
      */
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java
index 5ef3d39..5074480 100644
--- a/core/java/android/appwidget/AppWidgetProviderInfo.java
+++ b/core/java/android/appwidget/AppWidgetProviderInfo.java
@@ -281,6 +281,28 @@
         out.writeInt(this.widgetFeatures);
     }
 
+    @Override
+    public AppWidgetProviderInfo clone() {
+        AppWidgetProviderInfo that = new AppWidgetProviderInfo();
+        that.provider = this.provider == null ? null : this.provider.clone();
+        that.minWidth = this.minWidth;
+        that.minHeight = this.minHeight;
+        that.minResizeWidth = this.minResizeHeight;
+        that.minResizeHeight = this.minResizeHeight;
+        that.updatePeriodMillis = this.updatePeriodMillis;
+        that.initialLayout = that.initialLayout;
+        that.initialKeyguardLayout = this.initialKeyguardLayout;
+        that.configure = this.configure == null ? null : this.configure.clone();
+        that.label = this.label == null ? null : this.label.substring(0);
+        that.icon = this.icon;
+        that.previewImage = this.previewImage;
+        that.autoAdvanceViewId = this.autoAdvanceViewId;
+        that.resizeMode = this.resizeMode;
+        that.widgetCategory  = this.widgetCategory;
+        that.widgetFeatures = this.widgetFeatures;
+        return that;
+    }
+
     public int describeContents() {
         return 0;
     }
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 12eb800..750badd 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2150,7 +2150,10 @@
      * Group of bits indicating that RTL properties resolution is done.
      */
     static final int ALL_RTL_PROPERTIES_RESOLVED = PFLAG2_LAYOUT_DIRECTION_RESOLVED |
-            PFLAG2_TEXT_DIRECTION_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED;
+            PFLAG2_TEXT_DIRECTION_RESOLVED |
+            PFLAG2_TEXT_ALIGNMENT_RESOLVED |
+            PFLAG2_PADDING_RESOLVED |
+            PFLAG2_DRAWABLE_RESOLVED;
 
     // There are a couple of flags left in mPrivateFlags2
 
@@ -3299,6 +3302,11 @@
         int overScrollMode = mOverScrollMode;
         boolean initializeScrollbars = false;
 
+        boolean leftPaddingDefined = false;
+        boolean rightPaddingDefined = false;
+        boolean startPaddingDefined = false;
+        boolean endPaddingDefined = false;
+
         final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion;
 
         final int N = a.getIndexCount();
@@ -3312,10 +3320,13 @@
                     padding = a.getDimensionPixelSize(attr, -1);
                     mUserPaddingLeftInitial = padding;
                     mUserPaddingRightInitial = padding;
+                    leftPaddingDefined = true;
+                    rightPaddingDefined = true;
                     break;
                  case com.android.internal.R.styleable.View_paddingLeft:
                     leftPadding = a.getDimensionPixelSize(attr, -1);
                     mUserPaddingLeftInitial = leftPadding;
+                    leftPaddingDefined = true;
                     break;
                 case com.android.internal.R.styleable.View_paddingTop:
                     topPadding = a.getDimensionPixelSize(attr, -1);
@@ -3323,15 +3334,18 @@
                 case com.android.internal.R.styleable.View_paddingRight:
                     rightPadding = a.getDimensionPixelSize(attr, -1);
                     mUserPaddingRightInitial = rightPadding;
+                    rightPaddingDefined = true;
                     break;
                 case com.android.internal.R.styleable.View_paddingBottom:
                     bottomPadding = a.getDimensionPixelSize(attr, -1);
                     break;
                 case com.android.internal.R.styleable.View_paddingStart:
                     startPadding = a.getDimensionPixelSize(attr, UNDEFINED_PADDING);
+                    startPaddingDefined = true;
                     break;
                 case com.android.internal.R.styleable.View_paddingEnd:
                     endPadding = a.getDimensionPixelSize(attr, UNDEFINED_PADDING);
+                    endPaddingDefined = true;
                     break;
                 case com.android.internal.R.styleable.View_scrollX:
                     x = a.getDimensionPixelOffset(attr, 0);
@@ -3629,10 +3643,24 @@
             mUserPaddingRightInitial = padding;
         }
 
+        // RTL compatibility mode: pre Jelly Bean MR1 case OR no RTL support case.
+        // left / right padding are used if defined (meaning here nothing to do). If they are not
+        // defined and start / end padding are defined (e.g. in Frameworks resources), then we use
+        // start / end and resolve them as left / right (layout direction is not taken into account).
+        if (isRtlCompatibilityMode()) {
+            if (!leftPaddingDefined && startPaddingDefined) {
+                leftPadding = startPadding;
+            }
+            if (!rightPaddingDefined && endPaddingDefined) {
+                rightPadding = endPadding;
+            }
+        }
+
         // If the user specified the padding (either with android:padding or
         // android:paddingLeft/Top/Right/Bottom), use this padding, otherwise
         // use the default padding or the padding from the background drawable
-        // (stored at this point in mPadding*)
+        // (stored at this point in mPadding*). Padding resolution will happen later if
+        // RTL is supported.
         mUserPaddingLeftInitial = leftPadding >= 0 ? leftPadding : mPaddingLeft;
         mUserPaddingRightInitial = rightPadding >= 0 ? rightPadding : mPaddingRight;
         internalSetPadding(
@@ -11569,6 +11597,15 @@
     }
 
     /**
+     * Return true if we are in RTL compatibility mode (either before Jelly Bean MR1 or
+     * RTL not supported)
+     */
+    private boolean isRtlCompatibilityMode() {
+        final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion;
+        return targetSdkVersion < JELLY_BEAN_MR1 || !hasRtlSupport();
+    }
+
+    /**
      * @return true if RTL properties need resolution.
      */
     private boolean needRtlPropertiesResolution() {
@@ -11693,26 +11730,7 @@
      * @hide
      */
     public void resolvePadding() {
-        final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion;
-        if (targetSdkVersion < JELLY_BEAN_MR1 || !hasRtlSupport()) {
-            // Pre Jelly Bean MR1 case (compatibility mode) OR no RTL support case:
-            // left / right padding are used if defined. If they are not defined and start / end
-            // padding are defined (e.g. in Frameworks resources), then we use start / end and
-            // resolve them as left / right (layout direction is not taken into account).
-            if (mUserPaddingLeftInitial == UNDEFINED_PADDING &&
-                    mUserPaddingStart != UNDEFINED_PADDING) {
-                mUserPaddingLeft = mUserPaddingStart;
-            }
-            if (mUserPaddingRightInitial == UNDEFINED_PADDING &&
-                    mUserPaddingEnd != UNDEFINED_PADDING) {
-                mUserPaddingRight = mUserPaddingEnd;
-            }
-
-            mUserPaddingBottom = (mUserPaddingBottom >= 0) ? mUserPaddingBottom : mPaddingBottom;
-
-            internalSetPadding(mUserPaddingLeft, mPaddingTop, mUserPaddingRight,
-                    mUserPaddingBottom);
-        } else {
+        if (!isRtlCompatibilityMode()) {
             // Post Jelly Bean MR1 case: we need to take the resolved layout direction into account.
             // If start / end padding are defined, they will be resolved (hence overriding) to
             // left / right or right / left depending on the resolved layout direction.
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 6db40ba..438f792 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1616,6 +1616,7 @@
                     mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight);
                     if (!hwInitialized) {
                         mAttachInfo.mHardwareRenderer.invalidate(mHolder.getSurface());
+                        mFullRedrawNeeded = true;
                     }
                 }
             }
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 6264315..7f0af09 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -65,6 +65,7 @@
 import android.view.inputmethod.InputConnection;
 import android.view.inputmethod.InputConnectionWrapper;
 import android.view.inputmethod.InputMethodManager;
+import android.widget.RemoteViews.OnClickHandler;
 
 import com.android.internal.R;
 
@@ -5875,6 +5876,21 @@
     }
 
     /**
+     * Sets up the onClickHandler to be used by the RemoteViewsAdapter when inflating RemoteViews
+     * 
+     * @param handler The OnClickHandler to use when inflating RemoteViews.
+     * 
+     * @hide
+     */
+    public void setRemoteViewsOnClickHandler(OnClickHandler handler) {
+        // Ensure that we don't already have a RemoteViewsAdapter that is bound to an existing
+        // service handling the specified intent.
+        if (mRemoteAdapter != null) {
+            mRemoteAdapter.setRemoteViewsOnClickHandler(handler);
+        }
+    }
+
+    /**
      * This defers a notifyDataSetChanged on the pending RemoteViewsAdapter if it has not
      * connected yet.
      */
diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java
index 2266cea..90e949a 100644
--- a/core/java/android/widget/AdapterViewAnimator.java
+++ b/core/java/android/widget/AdapterViewAnimator.java
@@ -31,6 +31,7 @@
 import android.view.ViewGroup;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
+import android.widget.RemoteViews.OnClickHandler;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -992,6 +993,21 @@
         }
     }
 
+    /**
+     * Sets up the onClickHandler to be used by the RemoteViewsAdapter when inflating RemoteViews
+     * 
+     * @param handler The OnClickHandler to use when inflating RemoteViews.
+     * 
+     * @hide
+     */
+    public void setRemoteViewsOnClickHandler(OnClickHandler handler) {
+        // Ensure that we don't already have a RemoteViewsAdapter that is bound to an existing
+        // service handling the specified intent.
+        if (mRemoteViewsAdapter != null) {
+            mRemoteViewsAdapter.setRemoteViewsOnClickHandler(handler);
+        }
+    }
+
     @Override
     public void setSelection(int position) {
         setDisplayedChild(position);
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 4b5dfb8..8d83774 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -237,12 +237,11 @@
      * @hide
      */
     public void mergeRemoteViews(RemoteViews newRv) {
+        if (newRv == null) return;
         // We first copy the new RemoteViews, as the process of merging modifies the way the actions
         // reference the bitmap cache. We don't want to modify the object as it may need to
         // be merged and applied multiple times.
-        Parcel p = Parcel.obtain();
-        newRv.writeToParcel(p, 0);
-        RemoteViews copy = new RemoteViews(p);
+        RemoteViews copy = newRv.clone();
 
         HashMap<String, Action> map = new HashMap<String, Action>();
         if (mActions == null) {
@@ -261,7 +260,7 @@
         for (int i = 0; i < count; i++) {
             Action a = newActions.get(i);
             String key = newActions.get(i).getUniqueKey();
-            int mergeBehavior = map.get(key).mergeBehavior();
+            int mergeBehavior = newActions.get(i).mergeBehavior();
             if (map.containsKey(key) && mergeBehavior == Action.MERGE_REPLACE) {
                 mActions.remove(map.get(key));
                 map.remove(key);
@@ -530,9 +529,11 @@
             if (target instanceof AbsListView) {
                 AbsListView v = (AbsListView) target;
                 v.setRemoteViewsAdapter(intent);
+                v.setRemoteViewsOnClickHandler(handler);
             } else if (target instanceof AdapterViewAnimator) {
                 AdapterViewAnimator v = (AdapterViewAnimator) target;
                 v.setRemoteViewsAdapter(intent);
+                v.setRemoteViewsOnClickHandler(handler);
             }
         }
 
@@ -1579,23 +1580,12 @@
         recalculateMemoryUsage();
     }
 
-    @Override
-    public RemoteViews clone() {
-        RemoteViews that;
-        if (!hasLandscapeAndPortraitLayouts()) {
-            that = new RemoteViews(mPackage, mLayoutId);
 
-            if (mActions != null) {
-                that.mActions = (ArrayList<Action>)mActions.clone();
-            }
-        } else {
-            RemoteViews land = mLandscape.clone();
-            RemoteViews port = mPortrait.clone();
-            that = new RemoteViews(land, port);
-        }
-        // update the memory usage stats of the cloned RemoteViews
-        that.recalculateMemoryUsage();
-        return that;
+    public RemoteViews clone() {
+        Parcel p = Parcel.obtain();
+        writeToParcel(p, 0);
+        p.setDataPosition(0);
+        return new RemoteViews(p);
     }
 
     public String getPackage() {
diff --git a/core/java/android/widget/RemoteViewsAdapter.java b/core/java/android/widget/RemoteViewsAdapter.java
index f0109ce..e481702 100644
--- a/core/java/android/widget/RemoteViewsAdapter.java
+++ b/core/java/android/widget/RemoteViewsAdapter.java
@@ -36,6 +36,7 @@
 import android.view.View;
 import android.view.View.MeasureSpec;
 import android.view.ViewGroup;
+import android.widget.RemoteViews.OnClickHandler;
 
 import com.android.internal.widget.IRemoteViewsAdapterConnection;
 import com.android.internal.widget.IRemoteViewsFactory;
@@ -68,6 +69,7 @@
     private LayoutInflater mLayoutInflater;
     private RemoteViewsAdapterServiceConnection mServiceConnection;
     private WeakReference<RemoteAdapterConnectionCallback> mCallback;
+    private OnClickHandler mRemoteViewsOnClickHandler;
     private FixedSizeRemoteViewsCache mCache;
     private int mVisibleWindowLowerBound;
     private int mVisibleWindowUpperBound;
@@ -277,11 +279,11 @@
          * @param view the RemoteViews that was loaded. If null, the RemoteViews was not loaded
          *             successfully.
          */
-        public void onRemoteViewsLoaded(RemoteViews view) {
+        public void onRemoteViewsLoaded(RemoteViews view, OnClickHandler handler) {
             try {
                 // Remove all the children of this layout first
                 removeAllViews();
-                addView(view.apply(getContext(), this));
+                addView(view.apply(getContext(), this, handler));
             } catch (Exception e) {
                 Log.e(TAG, "Failed to apply RemoteViews.");
             }
@@ -330,7 +332,7 @@
                 // Notify all the references for that position of the newly loaded RemoteViews
                 final LinkedList<RemoteViewsFrameLayout> refs = mReferences.get(pos);
                 for (final RemoteViewsFrameLayout ref : refs) {
-                    ref.onRemoteViewsLoaded(view);
+                    ref.onRemoteViewsLoaded(view, mRemoteViewsOnClickHandler);
                 }
                 refs.clear();
 
@@ -421,7 +423,8 @@
         }
 
         private RemoteViewsFrameLayout createLoadingView(int position, View convertView,
-                ViewGroup parent, Object lock, LayoutInflater layoutInflater) {
+                ViewGroup parent, Object lock, LayoutInflater layoutInflater, OnClickHandler
+                handler) {
             // Create and return a new FrameLayout, and setup the references for this position
             final Context context = parent.getContext();
             RemoteViewsFrameLayout layout = new RemoteViewsFrameLayout(context);
@@ -433,7 +436,8 @@
                 if (mUserLoadingView != null) {
                     // Try to inflate user-specified loading view
                     try {
-                        View loadingView = mUserLoadingView.apply(parent.getContext(), parent);
+                        View loadingView = mUserLoadingView.apply(parent.getContext(), parent,
+                                handler);
                         loadingView.setTagInternal(com.android.internal.R.id.rowTypeId,
                                 new Integer(0));
                         layout.addView(loadingView);
@@ -448,7 +452,7 @@
                     // Use the size of the first row as a guide for the size of the loading view
                     if (mFirstViewHeight < 0) {
                         try {
-                            View firstView = mFirstView.apply(parent.getContext(), parent);
+                            View firstView = mFirstView.apply(parent.getContext(), parent, handler);
                             firstView.measure(
                                     MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                                     MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
@@ -815,6 +819,10 @@
         return mDataReady;
     }
 
+    public void setRemoteViewsOnClickHandler(OnClickHandler handler) {
+        mRemoteViewsOnClickHandler = handler;
+    }
+
     public void saveRemoteViewsCache() {
         final Pair<Intent.FilterComparison, Integer> key = new Pair<Intent.FilterComparison,
                 Integer> (new Intent.FilterComparison(mIntent), mAppWidgetId);
@@ -1102,7 +1110,7 @@
                     // Reuse the convert view where possible
                     if (layout != null) {
                         if (convertViewTypeId == typeId) {
-                            rv.reapply(context, convertViewChild);
+                            rv.reapply(context, convertViewChild, mRemoteViewsOnClickHandler);
                             return layout;
                         }
                         layout.removeAllViews();
@@ -1111,7 +1119,7 @@
                     }
 
                     // Otherwise, create a new view to be returned
-                    View newView = rv.apply(context, parent);
+                    View newView = rv.apply(context, parent, mRemoteViewsOnClickHandler);
                     newView.setTagInternal(com.android.internal.R.id.rowTypeId,
                             new Integer(typeId));
                     layout.addView(newView);
@@ -1127,7 +1135,7 @@
                     final RemoteViewsMetaData metaData = mCache.getMetaData();
                     synchronized (metaData) {
                         loadingView = metaData.createLoadingView(position, convertView, parent,
-                                mCache, mLayoutInflater);
+                                mCache, mLayoutInflater, mRemoteViewsOnClickHandler);
                     }
                     return loadingView;
                 } finally {
@@ -1140,7 +1148,7 @@
                 final RemoteViewsMetaData metaData = mCache.getMetaData();
                 synchronized (metaData) {
                     loadingView = metaData.createLoadingView(position, convertView, parent,
-                            mCache, mLayoutInflater);
+                            mCache, mLayoutInflater, mRemoteViewsOnClickHandler);
                 }
 
                 mRequestedViews.add(position, loadingView);
diff --git a/core/java/com/android/internal/widget/PasswordEntryKeyboardHelper.java b/core/java/com/android/internal/widget/PasswordEntryKeyboardHelper.java
index 26518eb..f8332c4 100644
--- a/core/java/com/android/internal/widget/PasswordEntryKeyboardHelper.java
+++ b/core/java/com/android/internal/widget/PasswordEntryKeyboardHelper.java
@@ -31,6 +31,7 @@
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
 import android.view.ViewRootImpl;
 import com.android.internal.R;
 
@@ -55,23 +56,56 @@
     private long[] mVibratePattern;
     private boolean mEnableHaptics = false;
 
+    private static final int NUMERIC = 0;
+    private static final int QWERTY = 1;
+    private static final int QWERTY_SHIFTED = 2;
+    private static final int SYMBOLS = 3;
+    private static final int SYMBOLS_SHIFTED = 4;
+
+    int mLayouts[] = new int[] {
+            R.xml.password_kbd_numeric,
+            R.xml.password_kbd_qwerty,
+            R.xml.password_kbd_qwerty_shifted,
+            R.xml.password_kbd_symbols,
+            R.xml.password_kbd_symbols_shift
+            };
+
+    private boolean mUsingScreenWidth;
+
     public PasswordEntryKeyboardHelper(Context context, KeyboardView keyboardView, View targetView) {
-        this(context, keyboardView, targetView, true);
+        this(context, keyboardView, targetView, true, null);
     }
 
     public PasswordEntryKeyboardHelper(Context context, KeyboardView keyboardView, View targetView,
             boolean useFullScreenWidth) {
+        this(context, keyboardView, targetView, useFullScreenWidth, null);
+    }
+
+    public PasswordEntryKeyboardHelper(Context context, KeyboardView keyboardView, View targetView,
+            boolean useFullScreenWidth, int layouts[]) {
         mContext = context;
         mTargetView = targetView;
         mKeyboardView = keyboardView;
-        if (useFullScreenWidth
-                || mKeyboardView.getLayoutParams().width == ViewGroup.LayoutParams.MATCH_PARENT) {
-            createKeyboards();
-        } else {
-            createKeyboardsWithSpecificSize(mKeyboardView.getLayoutParams().width,
-                    mKeyboardView.getLayoutParams().height);
-        }
         mKeyboardView.setOnKeyboardActionListener(this);
+        mUsingScreenWidth = useFullScreenWidth;
+        if (layouts != null) {
+            if (layouts.length != mLayouts.length) {
+                throw new RuntimeException("Wrong number of layouts");
+            }
+            for (int i = 0; i < mLayouts.length; i++) {
+                mLayouts[i] = layouts[i];
+            }
+        }
+        createKeyboards();
+    }
+
+    public void createKeyboards() {
+        LayoutParams lp = mKeyboardView.getLayoutParams();
+        if (mUsingScreenWidth || lp.width == ViewGroup.LayoutParams.MATCH_PARENT) {
+            createKeyboardsWithDefaultWidth();
+        } else {
+            createKeyboardsWithSpecificSize(lp.width, lp.height);
+        }
     }
 
     public void setEnableHaptics(boolean enabled) {
@@ -82,46 +116,40 @@
         return mKeyboardMode == KEYBOARD_MODE_ALPHA;
     }
 
-    private void createKeyboardsWithSpecificSize(int viewWidth, int viewHeight) {
-        mNumericKeyboard = new PasswordEntryKeyboard(mContext, R.xml.password_kbd_numeric,
-                viewWidth, viewHeight);
-        mQwertyKeyboard = new PasswordEntryKeyboard(mContext,
-                R.xml.password_kbd_qwerty, R.id.mode_normal, viewWidth, viewHeight);
+    private void createKeyboardsWithSpecificSize(int width, int height) {
+        mNumericKeyboard = new PasswordEntryKeyboard(mContext, mLayouts[NUMERIC], width, height);
+        mQwertyKeyboard = new PasswordEntryKeyboard(mContext, mLayouts[QWERTY], R.id.mode_normal,
+                width, height);
         mQwertyKeyboard.enableShiftLock();
 
-        mQwertyKeyboardShifted = new PasswordEntryKeyboard(mContext,
-                R.xml.password_kbd_qwerty_shifted,
-                R.id.mode_normal, viewWidth, viewHeight);
+        mQwertyKeyboardShifted = new PasswordEntryKeyboard(mContext, mLayouts[QWERTY_SHIFTED],
+                R.id.mode_normal, width, height);
         mQwertyKeyboardShifted.enableShiftLock();
         mQwertyKeyboardShifted.setShifted(true); // always shifted.
 
-        mSymbolsKeyboard = new PasswordEntryKeyboard(mContext, R.xml.password_kbd_symbols,
-                viewWidth, viewHeight);
+        mSymbolsKeyboard = new PasswordEntryKeyboard(mContext, mLayouts[SYMBOLS], width, height);
         mSymbolsKeyboard.enableShiftLock();
 
-        mSymbolsKeyboardShifted = new PasswordEntryKeyboard(mContext,
-                R.xml.password_kbd_symbols_shift, viewWidth, viewHeight);
+        mSymbolsKeyboardShifted = new PasswordEntryKeyboard(mContext, mLayouts[SYMBOLS_SHIFTED],
+                width, height);
         mSymbolsKeyboardShifted.enableShiftLock();
         mSymbolsKeyboardShifted.setShifted(true); // always shifted
     }
 
-    private void createKeyboards() {
-        mNumericKeyboard = new PasswordEntryKeyboard(mContext, R.xml.password_kbd_numeric);
-        mQwertyKeyboard = new PasswordEntryKeyboard(mContext,
-                R.xml.password_kbd_qwerty, R.id.mode_normal);
+    private void createKeyboardsWithDefaultWidth() {
+        mNumericKeyboard = new PasswordEntryKeyboard(mContext, mLayouts[NUMERIC]);
+        mQwertyKeyboard = new PasswordEntryKeyboard(mContext, mLayouts[QWERTY], R.id.mode_normal);
         mQwertyKeyboard.enableShiftLock();
 
-        mQwertyKeyboardShifted = new PasswordEntryKeyboard(mContext,
-                R.xml.password_kbd_qwerty_shifted,
+        mQwertyKeyboardShifted = new PasswordEntryKeyboard(mContext, mLayouts[QWERTY_SHIFTED],
                 R.id.mode_normal);
         mQwertyKeyboardShifted.enableShiftLock();
         mQwertyKeyboardShifted.setShifted(true); // always shifted.
 
-        mSymbolsKeyboard = new PasswordEntryKeyboard(mContext, R.xml.password_kbd_symbols);
+        mSymbolsKeyboard = new PasswordEntryKeyboard(mContext, mLayouts[SYMBOLS]);
         mSymbolsKeyboard.enableShiftLock();
 
-        mSymbolsKeyboardShifted = new PasswordEntryKeyboard(mContext,
-                R.xml.password_kbd_symbols_shift);
+        mSymbolsKeyboardShifted = new PasswordEntryKeyboard(mContext, mLayouts[SYMBOLS_SHIFTED]);
         mSymbolsKeyboardShifted.enableShiftLock();
         mSymbolsKeyboardShifted.setShifted(true); // always shifted
     }
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_alarm.png b/core/res/res/drawable-hdpi/ic_lockscreen_alarm.png
new file mode 100644
index 0000000..d7a8cfc
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_lockscreen_alarm.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_sim.png b/core/res/res/drawable-hdpi/ic_lockscreen_sim.png
new file mode 100644
index 0000000..7cf9e36
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_lockscreen_sim.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/lockscreen_protection_pattern.png b/core/res/res/drawable-hdpi/lockscreen_protection_pattern.png
new file mode 100644
index 0000000..681d8be
--- /dev/null
+++ b/core/res/res/drawable-hdpi/lockscreen_protection_pattern.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_delete.png b/core/res/res/drawable-hdpi/sym_keyboard_delete.png
old mode 100755
new mode 100644
index 59d78be..476d902
--- a/core/res/res/drawable-hdpi/sym_keyboard_delete.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_delete.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_enter.png b/core/res/res/drawable-hdpi/sym_keyboard_enter.png
new file mode 100644
index 0000000..d118af2
--- /dev/null
+++ b/core/res/res/drawable-hdpi/sym_keyboard_enter.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num0_no_plus.png b/core/res/res/drawable-hdpi/sym_keyboard_num0_no_plus.png
index 0e5f1e2..ad81bb3 100644
--- a/core/res/res/drawable-hdpi/sym_keyboard_num0_no_plus.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num0_no_plus.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num1.png b/core/res/res/drawable-hdpi/sym_keyboard_num1.png
old mode 100755
new mode 100644
index 0fc03ef..8d2468c
--- a/core/res/res/drawable-hdpi/sym_keyboard_num1.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num1.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num2.png b/core/res/res/drawable-hdpi/sym_keyboard_num2.png
old mode 100755
new mode 100644
index 283560b..cfa972b
--- a/core/res/res/drawable-hdpi/sym_keyboard_num2.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num2.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num3.png b/core/res/res/drawable-hdpi/sym_keyboard_num3.png
old mode 100755
new mode 100644
index 9a3b329..141833a
--- a/core/res/res/drawable-hdpi/sym_keyboard_num3.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num3.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num4.png b/core/res/res/drawable-hdpi/sym_keyboard_num4.png
old mode 100755
new mode 100644
index f13ff1a..07df14d
--- a/core/res/res/drawable-hdpi/sym_keyboard_num4.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num4.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num5.png b/core/res/res/drawable-hdpi/sym_keyboard_num5.png
old mode 100755
new mode 100644
index c251329..fbcc9bf
--- a/core/res/res/drawable-hdpi/sym_keyboard_num5.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num5.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num6.png b/core/res/res/drawable-hdpi/sym_keyboard_num6.png
old mode 100755
new mode 100644
index 4acba4c..9513b33
--- a/core/res/res/drawable-hdpi/sym_keyboard_num6.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num6.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num7.png b/core/res/res/drawable-hdpi/sym_keyboard_num7.png
old mode 100755
new mode 100644
index 14931c1..5ad25d8
--- a/core/res/res/drawable-hdpi/sym_keyboard_num7.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num7.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num8.png b/core/res/res/drawable-hdpi/sym_keyboard_num8.png
old mode 100755
new mode 100644
index d4973fd..97d5c0e
--- a/core/res/res/drawable-hdpi/sym_keyboard_num8.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num8.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/sym_keyboard_num9.png b/core/res/res/drawable-hdpi/sym_keyboard_num9.png
old mode 100755
new mode 100644
index 49cec66..a7d6a83
--- a/core/res/res/drawable-hdpi/sym_keyboard_num9.png
+++ b/core/res/res/drawable-hdpi/sym_keyboard_num9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_alarm.png b/core/res/res/drawable-mdpi/ic_lockscreen_alarm.png
new file mode 100644
index 0000000..330ade1
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_lockscreen_alarm.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_sim.png b/core/res/res/drawable-mdpi/ic_lockscreen_sim.png
new file mode 100644
index 0000000..2e259c3
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_lockscreen_sim.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/lockscreen_protection_pattern.png b/core/res/res/drawable-mdpi/lockscreen_protection_pattern.png
new file mode 100644
index 0000000..30bcea5
--- /dev/null
+++ b/core/res/res/drawable-mdpi/lockscreen_protection_pattern.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_delete.png b/core/res/res/drawable-mdpi/sym_keyboard_delete.png
index 43a033ea..74b836a 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_delete.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_delete.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_enter.png b/core/res/res/drawable-mdpi/sym_keyboard_enter.png
new file mode 100644
index 0000000..0fa53ac
--- /dev/null
+++ b/core/res/res/drawable-mdpi/sym_keyboard_enter.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num0_no_plus.png b/core/res/res/drawable-mdpi/sym_keyboard_num0_no_plus.png
index d23114d..9fefaea 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num0_no_plus.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num0_no_plus.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num1.png b/core/res/res/drawable-mdpi/sym_keyboard_num1.png
index aaac11b..1f37e32 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num1.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num1.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num2.png b/core/res/res/drawable-mdpi/sym_keyboard_num2.png
index 4372eb8..f899f78 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num2.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num2.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num3.png b/core/res/res/drawable-mdpi/sym_keyboard_num3.png
index 6f54c85..6a0f5ef 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num3.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num3.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num4.png b/core/res/res/drawable-mdpi/sym_keyboard_num4.png
index 3e50bb9..3a25bcd 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num4.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num4.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num5.png b/core/res/res/drawable-mdpi/sym_keyboard_num5.png
index c39ef44..064d4bf 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num5.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num5.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num6.png b/core/res/res/drawable-mdpi/sym_keyboard_num6.png
index ea88ceb..61ee0a6 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num6.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num6.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num7.png b/core/res/res/drawable-mdpi/sym_keyboard_num7.png
index ce800ba..b931d7b 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num7.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num7.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num8.png b/core/res/res/drawable-mdpi/sym_keyboard_num8.png
index 1a8ff94..f8d2891 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num8.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num8.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/sym_keyboard_num9.png b/core/res/res/drawable-mdpi/sym_keyboard_num9.png
index 8b344c0..056d067 100644
--- a/core/res/res/drawable-mdpi/sym_keyboard_num9.png
+++ b/core/res/res/drawable-mdpi/sym_keyboard_num9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_alarm.png b/core/res/res/drawable-xhdpi/ic_lockscreen_alarm.png
new file mode 100644
index 0000000..e6cceef
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_lockscreen_alarm.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_sim.png b/core/res/res/drawable-xhdpi/ic_lockscreen_sim.png
new file mode 100644
index 0000000..f4de96a
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_lockscreen_sim.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/lockscreen_protection_pattern.png b/core/res/res/drawable-xhdpi/lockscreen_protection_pattern.png
new file mode 100644
index 0000000..c13afe2
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/lockscreen_protection_pattern.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_delete.png b/core/res/res/drawable-xhdpi/sym_keyboard_delete.png
index ca936d1..45c14aa 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_delete.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_delete.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_enter.png b/core/res/res/drawable-xhdpi/sym_keyboard_enter.png
new file mode 100644
index 0000000..3b034fd
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_enter.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num0_no_plus.png b/core/res/res/drawable-xhdpi/sym_keyboard_num0_no_plus.png
index 95b542d..cdd256d 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num0_no_plus.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num0_no_plus.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num1.png b/core/res/res/drawable-xhdpi/sym_keyboard_num1.png
index decd584..d81d4b5 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num1.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num1.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num2.png b/core/res/res/drawable-xhdpi/sym_keyboard_num2.png
index 37948fb..8ae9faf 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num2.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num2.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num3.png b/core/res/res/drawable-xhdpi/sym_keyboard_num3.png
index 0e36ff2..ed6e90a 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num3.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num3.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num4.png b/core/res/res/drawable-xhdpi/sym_keyboard_num4.png
index f469a4a8..5cff39f 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num4.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num4.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num5.png b/core/res/res/drawable-xhdpi/sym_keyboard_num5.png
index 941f877..1c9358e 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num5.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num5.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num6.png b/core/res/res/drawable-xhdpi/sym_keyboard_num6.png
index eceec55..9a5cb6f 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num6.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num6.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num7.png b/core/res/res/drawable-xhdpi/sym_keyboard_num7.png
index 5b5d205..1bd5c6b 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num7.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num7.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num8.png b/core/res/res/drawable-xhdpi/sym_keyboard_num8.png
index ea776eb..9a33152 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num8.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num8.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/sym_keyboard_num9.png b/core/res/res/drawable-xhdpi/sym_keyboard_num9.png
index 29047fb..caa3113 100644
--- a/core/res/res/drawable-xhdpi/sym_keyboard_num9.png
+++ b/core/res/res/drawable-xhdpi/sym_keyboard_num9.png
Binary files differ
diff --git a/core/res/res/layout-land/keyguard_host_view.xml b/core/res/res/layout-land/keyguard_host_view.xml
index 01e1866..595762e 100644
--- a/core/res/res/layout-land/keyguard_host_view.xml
+++ b/core/res/res/layout-land/keyguard_host_view.xml
@@ -24,13 +24,15 @@
     android:id="@+id/keyguard_host_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:gravity="center_vertical"
     android:orientation="horizontal">
 
     <com.android.internal.policy.impl.keyguard.KeyguardWidgetPager
         android:id="@+id/app_widget_container"
         android:layout_width="0dip"
-        android:layout_height="match_parent"
-        android:layout_weight="1"
+        android:layout_height="230dip"
+        android:gravity="center"
+        android:layout_weight=".45"
         android:visibility="gone">
 
         <!-- TODO: Remove this once supported as a widget -->
@@ -44,7 +46,9 @@
         android:id="@+id/view_flipper"
         android:layout_width="0dip"
         android:layout_height="match_parent"
-        android:layout_weight="1"
+        android:layout_weight="0.55"
+        android:layout_marginLeft="8dip"
+        android:layout_marginRight="8dip"
         android:gravity="center">
 
         <!-- SelectorView is always used, so add it here. The rest are loaded dynamically -->
diff --git a/core/res/res/layout/keyguard_emergency_carrier_area.xml b/core/res/res/layout/keyguard_emergency_carrier_area.xml
new file mode 100644
index 0000000..62cbac4
--- /dev/null
+++ b/core/res/res/layout/keyguard_emergency_carrier_area.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License")
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!-- This contains emergency call button and carrier as shared by pin/pattern/password screens -->
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    android:gravity="center_horizontal"
+    android:layout_alignParentBottom="true">
+
+    <com.android.internal.policy.impl.keyguard.CarrierText
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:singleLine="true"
+        android:ellipsize="marquee"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:textSize="@dimen/kg_status_line_font_size"
+        android:layout_marginLeft="@dimen/kg_emergency_button_shift"
+        android:textColor="?android:attr/textColorSecondary"/>
+
+    <com.android.internal.policy.impl.keyguard.EmergencyButton
+        android:id="@+id/emergency_call_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:drawableLeft="@*android:drawable/lockscreen_emergency_button"
+        android:text="@string/kg_emergency_call_label"
+        style="?android:attr/buttonBarButtonStyle"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:textSize="@dimen/kg_status_line_font_size"
+        android:textColor="?android:attr/textColorSecondary"
+        android:layout_marginLeft="@dimen/kg_emergency_button_shift"
+        android:drawablePadding="8dip" />
+
+</LinearLayout>
diff --git a/core/res/res/layout/keyguard_navigation.xml b/core/res/res/layout/keyguard_navigation.xml
index a033101..d52bcb4 100644
--- a/core/res/res/layout/keyguard_navigation.xml
+++ b/core/res/res/layout/keyguard_navigation.xml
@@ -17,39 +17,19 @@
 */
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:gravity="left">
+    android:id="@+id/keyguard_click_area"
+    android:gravity="center">
 
-    <LinearLayout
-        android:id="@+id/keyguard_click_area"
-        android:layout_width="match_parent"
+    <!-- message area for security screen -->
+    <TextView
+        android:id="@+id/keyguard_message_area"
+        android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:orientation="horizontal"
-        style="?android:attr/buttonBarButtonStyle"
-        android:padding="10dip"
-        android:clickable="true">
-
-        <ImageView
-               android:src="?android:attr/homeAsUpIndicator"
-               android:layout_gravity="center_vertical|start"
-               android:layout_width="wrap_content"
-               android:layout_height="wrap_content"/>
-
-        <!-- message area for security screen -->
-        <TextView
-            android:id="@+id/keyguard_message_area"
-            android:layout_width="0dip"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:layout_gravity="end"
-            android:singleLine="true"
-            android:ellipsize="marquee"
-            android:layout_marginEnd="6dip"
-            android:layout_marginStart="6dip"
-            android:textAppearance="?android:attr/textAppearanceMedium"/>
-
-    </LinearLayout>
+        android:layout_gravity="start"
+        android:ellipsize="marquee"
+        android:layout_marginEnd="4dip"
+        android:layout_marginStart="4dip"
+        android:textSize="22dip"
+        android:textAppearance="?android:attr/textAppearanceMedium"/>
 
 </LinearLayout>
diff --git a/core/res/res/layout/keyguard_password_view.xml b/core/res/res/layout/keyguard_password_view.xml
index 4ea471e..e8ca98b 100644
--- a/core/res/res/layout/keyguard_password_view.xml
+++ b/core/res/res/layout/keyguard_password_view.xml
@@ -24,7 +24,16 @@
     android:layout_height="match_parent"
     android:gravity="center_horizontal">
 
-    <include layout="@layout/keyguard_navigation"/>
+    <LinearLayout
+        android:layout_height="0dip"
+        android:layout_width="match_parent"
+        android:layout_weight="1"
+        android:orientation="vertical"
+        android:gravity="center">
+
+        <include layout="@layout/keyguard_navigation"/>
+
+     </LinearLayout>
 
     <!-- Password entry field -->
     <!-- Note: the entire container is styled to look like the edit field,
@@ -33,9 +42,9 @@
         android:layout_gravity="center_vertical|fill_horizontal"
         android:layout_width="match_parent"
         android:orientation="horizontal"
-        android:background="@*android:drawable/lockscreen_password_field_dark"
-        android:layout_marginStart="16dip"
-        android:layout_marginEnd="16dip">
+        android:background="#70000000"
+        android:layout_marginStart="4dip"
+        android:layout_marginEnd="4dip">
 
         <EditText android:id="@+id/passwordEntry"
             android:layout_width="0dip"
@@ -79,11 +88,6 @@
 
     </LinearLayout>
 
-    <Space
-        android:layout_width="match_parent"
-        android:layout_height="0dip"
-        android:layout_weight="1"/>
-
     <!-- Numeric keyboard -->
     <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
         android:layout_width="match_parent"
@@ -97,4 +101,9 @@
         android:clickable="true"
     />
 
+    <Space
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/kg_secure_padding_height"
+        android:background="@drawable/lockscreen_protection_pattern" />
+
 </com.android.internal.policy.impl.keyguard.KeyguardPasswordView>
diff --git a/core/res/res/layout/keyguard_pattern_view.xml b/core/res/res/layout/keyguard_pattern_view.xml
index 356bce3..311f77f 100644
--- a/core/res/res/layout/keyguard_pattern_view.xml
+++ b/core/res/res/layout/keyguard_pattern_view.xml
@@ -28,18 +28,22 @@
     android:layout_height="match_parent"
     android:gravity="center_horizontal">
 
-    <include layout="@layout/keyguard_navigation"/>
+    <LinearLayout
+        android:layout_height="0dip"
+        android:layout_width="match_parent"
+        android:layout_weight="1"
+        android:orientation="vertical"
+        android:gravity="center">
 
-    <Space android:layout_gravity="fill" />
+        <include layout="@layout/keyguard_navigation"/>
 
-    <Button android:id="@+id/forgot_password_button"
-        android:layout_gravity="right"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
-        android:drawableLeft="@*android:drawable/lockscreen_forgot_password_button"
-        android:drawablePadding="0dip"
-        android:visibility="gone"/>
+        <Button android:id="@+id/forgot_password_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textSize="@dimen/kg_status_line_font_size"
+            android:visibility="gone"/>
+
+    </LinearLayout>
 
     <!-- We need MATCH_PARENT here only to force the size of the parent to be passed to
     the pattern view for it to compute its size. This is an unusual case, caused by
@@ -52,7 +56,11 @@
         android:layout_marginEnd="8dip"
         android:layout_marginBottom="4dip"
         android:layout_marginStart="8dip"
-        android:layout_gravity="center_horizontal"
-     />
+        android:layout_gravity="center_horizontal" />
+
+    <Space
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/kg_secure_padding_height"
+        android:background="@drawable/lockscreen_protection_pattern" />
 
 </com.android.internal.policy.impl.keyguard.KeyguardPatternView>
diff --git a/core/res/res/layout/keyguard_selector_view.xml b/core/res/res/layout/keyguard_selector_view.xml
index bf2fc22..8b2865e 100644
--- a/core/res/res/layout/keyguard_selector_view.xml
+++ b/core/res/res/layout/keyguard_selector_view.xml
@@ -31,6 +31,9 @@
         android:layout_width="match_parent"
         android:layout_height="0dip"
         android:layout_weight="0.45"
+        android:layout_marginTop="35dip"
+        android:layout_marginLeft="33dip"
+        android:layout_marginRight="33dip"
         android:visibility="gone">
             <!-- TODO: Remove this when supported as a widget -->
             <include layout="@layout/keyguard_status_view"/>
@@ -50,6 +53,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:focusable="true"
+            android:gravity="@integer/kg_selector_gravity"
 
             prvandroid:targetDrawables="@*android:array/lockscreen_targets_with_camera"
             prvandroid:targetDescriptions="@*android:array/lockscreen_target_descriptions_with_camera"
@@ -64,34 +68,13 @@
             prvandroid:glowRadius="@*android:dimen/glowpadview_glow_radius"
             prvandroid:pointDrawable="@*android:drawable/ic_lockscreen_glowdot"/>
 
-        <LinearLayout
+        <include layout="@layout/keyguard_emergency_carrier_area"
             android:id="@+id/keyguard_selector_fade_container"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:orientation="vertical"
             android:gravity="center_horizontal"
-            android:layout_alignParentBottom="true">
-
-            <com.android.internal.policy.impl.keyguard.CarrierText
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:singleLine="true"
-                android:ellipsize="marquee"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
-                android:textColor="?android:attr/textColorSecondary"
-                />
-
-            <com.android.internal.policy.impl.keyguard.EmergencyButton
-                android:id="@+id/emergency_call_button"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:drawableLeft="@*android:drawable/lockscreen_emergency_button"
-                android:text="@string/kg_emergency_call_label"
-                style="?android:attr/buttonBarButtonStyle"
-                android:drawablePadding="8dip" />
-
-        </LinearLayout>
+            android:layout_alignParentBottom="true" />
 
     </RelativeLayout>
 
diff --git a/core/res/res/layout/keyguard_sim_pin_view.xml b/core/res/res/layout/keyguard_sim_pin_view.xml
index 122484a..57c7ac6 100644
--- a/core/res/res/layout/keyguard_sim_pin_view.xml
+++ b/core/res/res/layout/keyguard_sim_pin_view.xml
@@ -25,12 +25,21 @@
     android:layout_height="match_parent"
     android:gravity="center_horizontal">
 
-    <include layout="@layout/keyguard_navigation"/>
-
-    <Space
-        android:layout_width="match_parent"
+    <LinearLayout
         android:layout_height="0dip"
-        android:layout_weight="1"/>
+        android:layout_width="match_parent"
+        android:layout_weight="1"
+        android:orientation="vertical"
+        android:gravity="center">
+
+        <ImageView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@drawable/ic_lockscreen_sim"/>
+
+        <include layout="@layout/keyguard_navigation"/>
+
+     </LinearLayout>
 
     <!-- Password entry field -->
     <!-- Note: the entire container is styled to look like the edit field,
@@ -39,8 +48,8 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
-        android:layout_marginEnd="6dip"
-        android:layout_marginStart="6dip"
+        android:layout_marginEnd="4dip"
+        android:layout_marginStart="4dip"
         android:gravity="center_vertical"
         android:background="@android:drawable/edit_text">
 
@@ -74,9 +83,14 @@
         android:layout_marginEnd="4dip"
         android:paddingTop="4dip"
         android:paddingBottom="4dip"
-        android:background="#80ffffff"
+        android:background="#40000000"
         android:keyBackground="@*android:drawable/btn_keyboard_key_ics"
         android:clickable="true"
     />
 
+    <Space
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/kg_secure_padding_height"
+        android:background="@drawable/lockscreen_protection_pattern" />
+
 </com.android.internal.policy.impl.keyguard.KeyguardSimPinView>
diff --git a/core/res/res/layout/keyguard_status_view.xml b/core/res/res/layout/keyguard_status_view.xml
index 170dd99..d8adc93 100644
--- a/core/res/res/layout/keyguard_status_view.xml
+++ b/core/res/res/layout/keyguard_status_view.xml
@@ -35,6 +35,7 @@
             android:id="@+id/clock_view"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_marginTop="-15.5dip"
             android:layout_marginEnd="@dimen/kg_status_line_font_right_margin"
             android:layout_gravity="end">
 
@@ -46,6 +47,7 @@
                 android:textSize="@dimen/kg_status_clock_font_size"
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:textColor="#ffffffff"
+                android:drawablePadding="2dip"
                 />
 
         </com.android.internal.policy.impl.keyguard.ClockView>
@@ -64,19 +66,21 @@
             />
 
         <TextView
-            android:id="@+id/owner_info"
+            android:id="@+id/alarm_status"
             android:layout_gravity="end"
-            android:layout_marginTop="16dp"
+            android:layout_marginTop="28dp"
             android:layout_marginEnd="@dimen/kg_status_line_font_right_margin"
             android:singleLine="true"
             android:ellipsize="marquee"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:textSize="@dimen/kg_status_line_font_size"
+            android:drawablePadding="4dip"
             />
 
         <TextView
-            android:id="@+id/alarm_status"
+            android:id="@+id/owner_info"
             android:layout_gravity="end"
+            android:layout_marginTop="4dp"
             android:layout_marginEnd="@dimen/kg_status_line_font_right_margin"
             android:singleLine="true"
             android:ellipsize="marquee"
@@ -87,6 +91,7 @@
         <TextView
             android:id="@+id/status1"
             android:layout_gravity="end"
+            android:layout_marginTop="4dp"
             android:layout_marginEnd="@dimen/kg_status_line_font_right_margin"
             android:singleLine="true"
             android:ellipsize="marquee"
diff --git a/core/res/res/values-land/arrays.xml b/core/res/res/values-land/arrays.xml
index 1cd9e74..240b9e4 100644
--- a/core/res/res/values-land/arrays.xml
+++ b/core/res/res/values-land/arrays.xml
@@ -22,16 +22,16 @@
     <!-- Resources for GlowPadView in LockScreen -->
     <array name="lockscreen_targets_when_silent">
         <item>@null</item>"
-        <item>@drawable/ic_lockscreen_unlock</item>
         <item>@drawable/ic_action_assist_generic</item>
         <item>@drawable/ic_lockscreen_soundon</item>
+        <item>@drawable/ic_lockscreen_unlock</item>
     </array>
 
     <array name="lockscreen_target_descriptions_when_silent">
         <item>@null</item>
-        <item>@string/description_target_unlock</item>
         <item>@string/description_target_search</item>
         <item>@string/description_target_soundon</item>
+        <item>@string/description_target_unlock</item>
     </array>
 
     <array name="lockscreen_direction_descriptions">
@@ -43,30 +43,30 @@
 
     <array name="lockscreen_targets_when_soundon">
         <item>@null</item>
-        <item>@drawable/ic_lockscreen_unlock</item>
         <item>@drawable/ic_action_assist_generic</item>
         <item>@drawable/ic_lockscreen_silent</item>
+        <item>@drawable/ic_lockscreen_unlock</item>
     </array>
 
     <array name="lockscreen_target_descriptions_when_soundon">
         <item>@null</item>
-        <item>@string/description_target_unlock</item>
         <item>@string/description_target_search</item>
         <item>@string/description_target_silent</item>
+        <item>@string/description_target_unlock</item>
     </array>
 
     <array name="lockscreen_targets_with_camera">
         <item>@null</item>
-        <item>@drawable/ic_lockscreen_unlock</item>
         <item>@drawable/ic_action_assist_generic</item>
         <item>@drawable/ic_lockscreen_camera</item>
+        <item>@drawable/ic_lockscreen_unlock</item>
     </array>
 
     <array name="lockscreen_target_descriptions_with_camera">
         <item>@null</item>
-        <item>@string/description_target_unlock</item>
         <item>@string/description_target_search</item>
         <item>@string/description_target_camera</item>
+        <item>@string/description_target_unlock</item>
     </array>
 
 </resources>
diff --git a/core/res/res/values-land/dimens.xml b/core/res/res/values-land/dimens.xml
index 6f96852..07f62ed 100644
--- a/core/res/res/values-land/dimens.xml
+++ b/core/res/res/values-land/dimens.xml
@@ -43,4 +43,11 @@
     <!-- Size of clock font in LockScreen on Unsecure unlock screen. -->
     <dimen name="keyguard_lockscreen_clock_font_size">70sp</dimen>
 
+    <!-- Shift emergency button from the left edge by this amount.  Used by landscape layout on
+         phones -->
+    <dimen name="kg_emergency_button_shift">30dp</dimen>
+
+    <!-- Space reserved at the bottom of secure views (pin/pattern/password/SIM pin/SIM puk) -->
+    <dimen name="kg_secure_padding_height">0dp</dimen>
+
 </resources>
diff --git a/core/res/res/values-land/integers.xml b/core/res/res/values-land/integers.xml
new file mode 100644
index 0000000..1b8f575
--- /dev/null
+++ b/core/res/res/values-land/integers.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources>
+    <integer name="kg_security_flip_duration">150</integer>
+    <integer name="kg_security_fade_duration">150</integer>
+
+    <!-- Gravity to make KeyguardSelectorView work in multiple orientations
+        0x13 == "left|center_vertical" -->
+    <integer name="kg_selector_gravity">0x13</integer>
+</resources>
\ No newline at end of file
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 114b9c7..e860dfe 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -261,12 +261,28 @@
     <dimen name="kg_status_clock_font_size">94dp</dimen>
 
     <!-- Size of the date font in keyguard's status view  -->
-    <dimen name="kg_status_date_font_size">24dp</dimen>
+    <dimen name="kg_status_date_font_size">17dp</dimen>
 
     <!-- Size of the generic status lines keyguard's status view  -->
-    <dimen name="kg_status_line_font_size">12sp</dimen>
+    <dimen name="kg_status_line_font_size">14sp</dimen>
 
     <!-- Size of margin on the right of keyguard's status view -->
-    <dimen name="kg_status_line_font_right_margin">32dp</dimen>
+    <dimen name="kg_status_line_font_right_margin">0dp</dimen>
+
+    <!-- Horizontal gap between keys in PIN and SIM PIN numeric keyboards in keyguard -->
+    <dimen name="kg_key_horizontal_gap">0dp</dimen>
+
+    <!-- Horizontal gap between keys in PIN and SIM PIN numeric keyboards in keyguard -->
+    <dimen name="kg_key_vertical_gap">0dp</dimen>
+
+    <!-- Horizontal gap between keys in PIN and SIM PIN numeric keyboards in keyguard -->
+    <dimen name="kg_pin_key_height">60dp</dimen>
+
+    <!-- Shift emergency button from the left edge by this amount.  Used by landscape layout on
+         phones -->
+    <dimen name="kg_emergency_button_shift">0dp</dimen>
+
+    <!-- Space reserved at the bottom of secure views (pin/pattern/password/SIM pin/SIM puk) -->
+    <dimen name="kg_secure_padding_height">46dp</dimen>
 
 </resources>
diff --git a/core/res/res/values/donottranslate-cldr.xml b/core/res/res/values/donottranslate-cldr.xml
index 92ea1bf..0587c165 100644
--- a/core/res/res/values/donottranslate-cldr.xml
+++ b/core/res/res/values/donottranslate-cldr.xml
@@ -57,5 +57,4 @@
     <string name="full_wday_month_day_no_year">EEEE, MMMM d</string>
     <string name="abbrev_wday_month_day_no_year">EEE, MMMM d</string>
     <string name="abbrev_wday_month_day_year">EEE, MMM d, yyyy</string>
-    <string name="keyguard_wday_day_month">EEE <b>d</b> MMM</string>
 </resources>
diff --git a/core/res/res/values/integers.xml b/core/res/res/values/integers.xml
index 6d49a91..4b79d1f 100644
--- a/core/res/res/values/integers.xml
+++ b/core/res/res/values/integers.xml
@@ -19,4 +19,8 @@
 <resources>
     <integer name="kg_security_flip_duration">75</integer>
     <integer name="kg_security_fade_duration">75</integer>
+
+    <!-- Gravity to make KeyguardSelectorView work in multiple orientations
+        0x31 == "top|center_horizontal" -->
+    <integer name="kg_selector_gravity">0x31</integer>
 </resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 6f37d8e..c90f4f2 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3902,6 +3902,5 @@
        "Raise volume above safe level?\nListening at high volume for long periods may damage your hearing."
     </string>
 
-    <string name="kg_temp_back_string"> &lt; </string> <!-- TODO: remove this -->
 
 </resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 3936ed4..d85e581 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -957,6 +957,7 @@
   <java-symbol type="drawable" name="ic_lockscreen_silent" />
   <java-symbol type="drawable" name="ic_lockscreen_unlock" />
   <java-symbol type="drawable" name="ic_action_assist_generic" />
+  <java-symbol type="drawable" name="ic_lockscreen_alarm" />
   <java-symbol type="drawable" name="notification_bg" />
   <java-symbol type="drawable" name="notification_bg_low" />
   <java-symbol type="drawable" name="notification_template_icon_bg" />
@@ -1079,6 +1080,7 @@
   <java-symbol type="xml" name="password_kbd_qwerty_shifted" />
   <java-symbol type="xml" name="password_kbd_symbols" />
   <java-symbol type="xml" name="password_kbd_symbols_shift" />
+  <java-symbol type="xml" name="kg_password_kbd_numeric" />
   <java-symbol type="xml" name="power_profile" />
   <java-symbol type="xml" name="time_zones_by_country" />
   <java-symbol type="xml" name="sms_short_codes" />
@@ -1362,7 +1364,6 @@
   <java-symbol type="string" name="lockscreen_too_many_failed_pin_attempts_dialog_message" />
   <java-symbol type="string" name="lockscreen_unlock_label" />
   <java-symbol type="string" name="status_bar_device_locked" />
-  <java-symbol type="string" name="keyguard_wday_day_month" />
   <java-symbol type="style" name="Animation.LockScreen" />
   <java-symbol type="style" name="Theme.Dialog.RecentApplications" />
   <java-symbol type="style" name="Theme.ExpandedMenu" />
diff --git a/core/res/res/xml/kg_password_kbd_numeric.xml b/core/res/res/xml/kg_password_kbd_numeric.xml
new file mode 100755
index 0000000..93b32af
--- /dev/null
+++ b/core/res/res/xml/kg_password_kbd_numeric.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
+    android:keyWidth="33.33%p"
+    android:horizontalGap="@dimen/kg_key_horizontal_gap"
+    android:verticalGap="@dimen/kg_key_vertical_gap"
+    android:keyHeight="@dimen/kg_pin_key_height">
+
+    <Row android:rowEdgeFlags="top">
+        <Key android:codes="49" android:keyIcon="@*android:drawable/sym_keyboard_num1"
+             android:keyEdgeFlags="left"/>
+        <Key android:codes="50" android:keyIcon="@*android:drawable/sym_keyboard_num2"/>
+        <Key android:codes="51" android:keyIcon="@*android:drawable/sym_keyboard_num3"
+             android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row>
+        <Key android:codes="52" android:keyIcon="@*android:drawable/sym_keyboard_num4"
+             android:keyEdgeFlags="left"/>
+        <Key android:codes="53" android:keyIcon="@*android:drawable/sym_keyboard_num5"/>
+        <Key android:codes="54" android:keyIcon="@*android:drawable/sym_keyboard_num6"
+             android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row>
+        <Key android:codes="55" android:keyIcon="@*android:drawable/sym_keyboard_num7"
+             android:keyEdgeFlags="left"/>
+        <Key android:codes="56" android:keyIcon="@*android:drawable/sym_keyboard_num8"/>
+        <Key android:codes="57" android:keyIcon="@*android:drawable/sym_keyboard_num9"
+             android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row android:rowEdgeFlags="bottom">
+        <Key android:codes="48" android:keyIcon="@*android:drawable/sym_keyboard_num0_no_plus"
+             android:keyWidth="33.33%p"
+             android:keyEdgeFlags="left"/>
+        <Key android:codes="10" android:keyIcon="@*android:drawable/sym_keyboard_enter"
+             android:keyWidth="66.67%p"
+             android:keyEdgeFlags="right"/>
+    </Row>
+
+</Keyboard>
diff --git a/core/res/res/xml/password_kbd_numeric.xml b/core/res/res/xml/password_kbd_numeric.xml
index 560f867..7593ad8 100755
--- a/core/res/res/xml/password_kbd_numeric.xml
+++ b/core/res/res/xml/password_kbd_numeric.xml
@@ -51,7 +51,7 @@
     <Row android:rowEdgeFlags="bottom">
         <Key android:codes="48" android:keyIcon="@drawable/sym_keyboard_num0_no_plus"
              android:keyWidth="66.66%p" android:keyEdgeFlags="left"/>
-        <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_ok"
+        <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_enter"
              android:keyEdgeFlags="right"/>
     </Row>
 
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java
index 92bc93c..4f2545f 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java
@@ -122,7 +122,15 @@
         mPasswordEntry = (EditText) findViewById(R.id.passwordEntry);
         mPasswordEntry.setOnEditorActionListener(this);
 
-        mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false);
+        mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false,
+                new int[] {
+                    R.xml.kg_password_kbd_numeric,
+                    com.android.internal.R.xml.password_kbd_qwerty,
+                    com.android.internal.R.xml.password_kbd_qwerty_shifted,
+                    com.android.internal.R.xml.password_kbd_symbols,
+                    com.android.internal.R.xml.password_kbd_symbols_shift
+                    }
+        );
         mKeyboardHelper.setEnableHaptics(mLockPatternUtils.isTactileFeedbackEnabled());
 
         boolean imeOrDeleteButtonVisible = false;
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPatternView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPatternView.java
index 780f117..e4b7798 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPatternView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardPatternView.java
@@ -31,7 +31,7 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.widget.Button;
-import android.widget.GridLayout;
+import android.widget.LinearLayout;
 
 import com.android.internal.widget.LockPatternUtils;
 import com.android.internal.widget.LockPatternView;
@@ -40,7 +40,7 @@
 import java.io.IOException;
 import java.util.List;
 
-public class KeyguardPatternView extends GridLayout implements KeyguardSecurityView {
+public class KeyguardPatternView extends LinearLayout implements KeyguardSecurityView {
 
     private static final String TAG = "SecurityPatternView";
     private static final boolean DEBUG = false;
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java
index bc55008..f913519 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPinView.java
@@ -82,7 +82,14 @@
         mPinEntry.setOnEditorActionListener(this);
 
         mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
-        mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false);
+        mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false,
+                new int[] {
+                R.xml.kg_password_kbd_numeric,
+                com.android.internal.R.xml.password_kbd_qwerty,
+                com.android.internal.R.xml.password_kbd_qwerty_shifted,
+                com.android.internal.R.xml.password_kbd_symbols,
+                com.android.internal.R.xml.password_kbd_symbols_shift
+                });
         mKeyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
         mKeyboardHelper.setEnableHaptics(mLockPatternUtils.isTactileFeedbackEnabled());
 
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java
index e04bff9..d4bed25 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSimPukView.java
@@ -96,7 +96,14 @@
         mDelPinButton.setOnClickListener(this);
 
         mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
-        mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false);
+        mKeyboardHelper = new PasswordEntryKeyboardHelper(mContext, mKeyboardView, this, false,
+                new int[] {
+                R.xml.kg_password_kbd_numeric,
+                com.android.internal.R.xml.password_kbd_qwerty,
+                com.android.internal.R.xml.password_kbd_qwerty_shifted,
+                com.android.internal.R.xml.password_kbd_symbols,
+                com.android.internal.R.xml.password_kbd_symbols_shift
+                });
         mKeyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
         mKeyboardHelper.setEnableHaptics(mLockPatternUtils.isTactileFeedbackEnabled());
 
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java
index b30913a..220feb3 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java
@@ -102,7 +102,8 @@
     public KeyguardStatusViewManager(View view) {
         if (DEBUG) Log.v(TAG, "KeyguardStatusViewManager()");
         mContainer = view;
-        mDateFormatString = getContext().getResources().getText(R.string.keyguard_wday_day_month);
+        mDateFormatString = getContext().getResources().getText(
+                com.android.internal.R.string.abbrev_wday_month_day_no_year);
         mLockPatternUtils = new LockPatternUtils(view.getContext());
         mUpdateMonitor = KeyguardUpdateMonitor.getInstance(view.getContext());
 
@@ -113,7 +114,7 @@
         mClockView = (ClockView) view.findViewById(R.id.clock_view);
 
         // Use custom font in mDateView
-        mDateView.setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL));
+        mDateView.setTypeface(Typeface.SANS_SERIF);
 
         // Required to get Marquee to work.
         final View marqueeViews[] = { mDateView, mStatus1View, mOwnerInfoView, mAlarmStatusView };
@@ -183,6 +184,7 @@
                 Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED, 1, UserHandle.USER_CURRENT) != 0;
         String text = Settings.Secure.getStringForUser(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO,
                 UserHandle.USER_CURRENT);
+        text = text.trim(); // Remove trailing newlines
         if (ownerInfoEnabled && !TextUtils.isEmpty(text)) {
             maybeSetUpperCaseText(mOwnerInfoView, text);
             mOwnerInfoView.setVisibility(View.VISIBLE);
@@ -228,8 +230,7 @@
     }
 
     private void maybeSetUpperCaseText(TextView textView, CharSequence text) {
-        if (KeyguardViewManager.USE_UPPER_CASE
-                && (textView == mDateView)) { // currently only required for date view
+        if (KeyguardViewManager.USE_UPPER_CASE) { // currently only required for date view
             textView.setText(text != null ? text.toString().toUpperCase() : null);
         } else {
             textView.setText(text);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
index 14e4b67..ebdb116 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -46,7 +46,7 @@
 public class KeyguardViewManager {
     private final static boolean DEBUG = false;
     private static String TAG = "KeyguardViewManager";
-    public static boolean USE_UPPER_CASE = false;
+    public static boolean USE_UPPER_CASE = true;
 
     private final Context mContext;
     private final ViewManager mViewManager;
diff --git a/services/java/com/android/server/AppWidgetServiceImpl.java b/services/java/com/android/server/AppWidgetServiceImpl.java
index 8ec67c4..e77f8cf 100644
--- a/services/java/com/android/server/AppWidgetServiceImpl.java
+++ b/services/java/com/android/server/AppWidgetServiceImpl.java
@@ -534,6 +534,7 @@
         final long ident = Binder.clearCallingIdentity();
         try {
             synchronized (mAppWidgetIds) {
+                options = cloneIfLocalBinder(options);
                 ensureStateLoadedLocked();
                 AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
                 if (id == null) {
@@ -817,7 +818,7 @@
             ensureStateLoadedLocked();
             AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
             if (id != null && id.provider != null && !id.provider.zombie) {
-                return id.provider.info;
+                return cloneIfLocalBinder(id.provider.info);
             }
             return null;
         }
@@ -828,7 +829,7 @@
             ensureStateLoadedLocked();
             AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
             if (id != null) {
-                return id.views;
+                return cloneIfLocalBinder(id.views);
             }
             return null;
         }
@@ -842,7 +843,7 @@
             for (int i = 0; i < N; i++) {
                 Provider p = mInstalledProviders.get(i);
                 if (!p.zombie) {
-                    result.add(p.info);
+                    result.add(cloneIfLocalBinder(p.info));
                 }
             }
             return result;
@@ -881,6 +882,7 @@
 
     public void updateAppWidgetOptions(int appWidgetId, Bundle options) {
         synchronized (mAppWidgetIds) {
+            options = cloneIfLocalBinder(options);
             ensureStateLoadedLocked();
             AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
 
@@ -907,7 +909,7 @@
             ensureStateLoadedLocked();
             AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
             if (id != null && id.options != null) {
-                return id.options;
+                return cloneIfLocalBinder(id.options);
             } else {
                 return Bundle.EMPTY;
             }
@@ -1062,6 +1064,34 @@
         }
     }
 
+    private boolean isLocalBinder() {
+        return Process.myPid() == Binder.getCallingPid();
+    }
+
+    private RemoteViews cloneIfLocalBinder(RemoteViews rv) {
+        if (isLocalBinder() && rv != null) {
+            return rv.clone();
+        }
+        return rv;
+    }
+
+    private AppWidgetProviderInfo cloneIfLocalBinder(AppWidgetProviderInfo info) {
+        if (isLocalBinder() && info != null) {
+            return info.clone();
+        }
+        return info;
+    }
+
+    private Bundle cloneIfLocalBinder(Bundle bundle) {
+        // Note: this is only a shallow copy. For now this will be fine, but it could be problematic
+        // if we start adding objects to the options. Further, it would only be an issue if keyguard
+        // used such options.
+        if (isLocalBinder() && bundle != null) {
+            return (Bundle) bundle.clone();
+        }
+        return bundle;
+    }
+
     public int[] startListening(IAppWidgetHost callbacks, String packageName, int hostId,
             List<RemoteViews> updatedViews) {
         int callingUid = enforceCallingUid(packageName);
@@ -1078,7 +1108,7 @@
             for (int i = 0; i < N; i++) {
                 AppWidgetId id = instances.get(i);
                 updatedIds[i] = id.appWidgetId;
-                updatedViews.add(id.views);
+                updatedViews.add(cloneIfLocalBinder(id.views));
             }
             return updatedIds;
         }
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 15fc479..9f01eca 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -2451,6 +2451,21 @@
                 }
             }
 
+            // Cull any packages that run as system-domain uids but do not define their
+            // own backup agents
+            for (int i = 0; i < packagesToBackup.size(); ) {
+                PackageInfo pkg = packagesToBackup.get(i);
+                if ((pkg.applicationInfo.uid < Process.FIRST_APPLICATION_UID)
+                        && (pkg.applicationInfo.backupAgentName == null)) {
+                    if (MORE_DEBUG) {
+                        Slog.i(TAG, "... ignoring non-agent system package " + pkg.packageName);
+                    }
+                    packagesToBackup.remove(i);
+                } else {
+                    i++;
+                }
+            }
+
             FileOutputStream ofstream = new FileOutputStream(mOutputFile.getFileDescriptor());
             OutputStream out = null;
 
@@ -3669,29 +3684,37 @@
                                 // Fall through to IGNORE if the app explicitly disallows backup
                                 final int flags = pkgInfo.applicationInfo.flags;
                                 if ((flags & ApplicationInfo.FLAG_ALLOW_BACKUP) != 0) {
-                                    // Verify signatures against any installed version; if they
-                                    // don't match, then we fall though and ignore the data.  The
-                                    // signatureMatch() method explicitly ignores the signature
-                                    // check for packages installed on the system partition, because
-                                    // such packages are signed with the platform cert instead of
-                                    // the app developer's cert, so they're different on every
-                                    // device.
-                                    if (signaturesMatch(sigs, pkgInfo)) {
-                                        if (pkgInfo.versionCode >= version) {
-                                            Slog.i(TAG, "Sig + version match; taking data");
-                                            policy = RestorePolicy.ACCEPT;
+                                    // Restore system-uid-space packages only if they have
+                                    // defined a custom backup agent
+                                    if ((pkgInfo.applicationInfo.uid >= Process.FIRST_APPLICATION_UID)
+                                            || (pkgInfo.applicationInfo.backupAgentName != null)) {
+                                        // Verify signatures against any installed version; if they
+                                        // don't match, then we fall though and ignore the data.  The
+                                        // signatureMatch() method explicitly ignores the signature
+                                        // check for packages installed on the system partition, because
+                                        // such packages are signed with the platform cert instead of
+                                        // the app developer's cert, so they're different on every
+                                        // device.
+                                        if (signaturesMatch(sigs, pkgInfo)) {
+                                            if (pkgInfo.versionCode >= version) {
+                                                Slog.i(TAG, "Sig + version match; taking data");
+                                                policy = RestorePolicy.ACCEPT;
+                                            } else {
+                                                // The data is from a newer version of the app than
+                                                // is presently installed.  That means we can only
+                                                // use it if the matching apk is also supplied.
+                                                Slog.d(TAG, "Data version " + version
+                                                        + " is newer than installed version "
+                                                        + pkgInfo.versionCode + " - requiring apk");
+                                                policy = RestorePolicy.ACCEPT_IF_APK;
+                                            }
                                         } else {
-                                            // The data is from a newer version of the app than
-                                            // is presently installed.  That means we can only
-                                            // use it if the matching apk is also supplied.
-                                            Slog.d(TAG, "Data version " + version
-                                                    + " is newer than installed version "
-                                                    + pkgInfo.versionCode + " - requiring apk");
-                                            policy = RestorePolicy.ACCEPT_IF_APK;
+                                            Slog.w(TAG, "Restore manifest signatures do not match "
+                                                    + "installed application for " + info.packageName);
                                         }
                                     } else {
-                                        Slog.w(TAG, "Restore manifest signatures do not match "
-                                                + "installed application for " + info.packageName);
+                                        Slog.w(TAG, "Package " + info.packageName
+                                                + " is system level with no agent");
                                     }
                                 } else {
                                     if (DEBUG) Slog.i(TAG, "Restore manifest from "