Merge "Fix 5185505: Update DevicePolicyManager to support weak biometric security."
diff --git a/api/current.txt b/api/current.txt
index f380cf9..d4acca9 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -23714,7 +23714,7 @@
     field public static final int FLAGS_CHANGED = 4; // 0x4
     field public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 1; // 0x1
     field public static final int FLAG_ALT_FOCUSABLE_IM = 131072; // 0x20000
-    field public static final int FLAG_BLUR_BEHIND = 4; // 0x4
+    field public static final deprecated int FLAG_BLUR_BEHIND = 4; // 0x4
     field public static final int FLAG_DIM_BEHIND = 2; // 0x2
     field public static final int FLAG_DISMISS_KEYGUARD = 4194304; // 0x400000
     field public static final int FLAG_DITHER = 4096; // 0x1000
diff --git a/core/java/android/animation/ObjectAnimator.java b/core/java/android/animation/ObjectAnimator.java
index 31c5f8d..d2d66b6 100644
--- a/core/java/android/animation/ObjectAnimator.java
+++ b/core/java/android/animation/ObjectAnimator.java
@@ -351,7 +351,7 @@
     @Override
     public void start() {
         if (DBG) {
-            Log.d("ObjectAnimator", "Anim target, duration" + mTarget + ", " + getDuration());
+            Log.d("ObjectAnimator", "Anim target, duration: " + mTarget + ", " + getDuration());
             for (int i = 0; i < mValues.length; ++i) {
                 PropertyValuesHolder pvh = mValues[i];
                 ArrayList<Keyframe> keyframes = pvh.mKeyframeSet.mKeyframes;
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 8275cbd..2c2a493 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -372,6 +372,7 @@
         IInstrumentationWatcher instrumentationWatcher;
         int debugMode;
         boolean restrictedBackupMode;
+        boolean persistent;
         Configuration config;
         CompatibilityInfo compatInfo;
         boolean handlingProfiling;
@@ -644,9 +645,9 @@
                 ComponentName instrumentationName, String profileFile,
                 ParcelFileDescriptor profileFd, boolean autoStopProfiler,
                 Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher,
-                int debugMode, boolean isRestrictedBackupMode, Configuration config,
-                CompatibilityInfo compatInfo, Map<String, IBinder> services,
-                Bundle coreSettings) {
+                int debugMode, boolean isRestrictedBackupMode, boolean persistent,
+                Configuration config, CompatibilityInfo compatInfo,
+                Map<String, IBinder> services, Bundle coreSettings) {
 
             if (services != null) {
                 // Setup the service cache in the ServiceManager
@@ -666,6 +667,7 @@
             data.instrumentationWatcher = instrumentationWatcher;
             data.debugMode = debugMode;
             data.restrictedBackupMode = isRestrictedBackupMode;
+            data.persistent = persistent;
             data.config = config;
             data.compatInfo = compatInfo;
             queueOrSendMessage(H.BIND_APPLICATION, data);
@@ -3687,6 +3689,16 @@
         Process.setArgV0(data.processName);
         android.ddm.DdmHandleAppName.setAppName(data.processName);
 
+        if (data.persistent) {
+            // Persistent processes on low-memory devices do not get to
+            // use hardware accelerated drawing, since this can add too much
+            // overhead to the process.
+            Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
+            if (!ActivityManager.isHighEndGfx(display)) {
+                HardwareRenderer.disable(false);
+            }
+        }
+
         if (data.profileFd != null) {
             data.startProfiling();
         }
@@ -4242,7 +4254,7 @@
     }
 
     public static final ActivityThread systemMain() {
-        HardwareRenderer.disable();
+        HardwareRenderer.disable(true);
         ActivityThread thread = new ActivityThread();
         thread.attach(true);
         return thread;
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index 0a6fdd4..cde06cd 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -267,13 +267,14 @@
             IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
             int testMode = data.readInt();
             boolean restrictedBackupMode = (data.readInt() != 0);
+            boolean persistent = (data.readInt() != 0);
             Configuration config = Configuration.CREATOR.createFromParcel(data);
             CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
             HashMap<String, IBinder> services = data.readHashMap(null);
             Bundle coreSettings = data.readBundle();
             bindApplication(packageName, info,
                             providers, testName, profileName, profileFd, autoStopProfiler,
-                            testArgs, testWatcher, testMode, restrictedBackupMode,
+                            testArgs, testWatcher, testMode, restrictedBackupMode, persistent,
                             config, compatInfo, services, coreSettings);
             return true;
         }
@@ -811,8 +812,8 @@
     public final void bindApplication(String packageName, ApplicationInfo info,
             List<ProviderInfo> providers, ComponentName testName, String profileName,
             ParcelFileDescriptor profileFd, boolean autoStopProfiler, Bundle testArgs,
-            IInstrumentationWatcher testWatcher, int debugMode,
-            boolean restrictedBackupMode, Configuration config, CompatibilityInfo compatInfo,
+            IInstrumentationWatcher testWatcher, int debugMode, boolean restrictedBackupMode,
+            boolean persistent, Configuration config, CompatibilityInfo compatInfo,
             Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
         Parcel data = Parcel.obtain();
         data.writeInterfaceToken(IApplicationThread.descriptor);
@@ -837,6 +838,7 @@
         data.writeStrongInterface(testWatcher);
         data.writeInt(debugMode);
         data.writeInt(restrictedBackupMode ? 1 : 0);
+        data.writeInt(persistent ? 1 : 0);
         config.writeToParcel(data, 0);
         compatInfo.writeToParcel(data, 0);
         data.writeMap(services);
diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java
index 9ae5ab1..5d200b4 100644
--- a/core/java/android/app/IApplicationThread.java
+++ b/core/java/android/app/IApplicationThread.java
@@ -88,8 +88,8 @@
     static final int DEBUG_WAIT = 2;
     void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers,
             ComponentName testName, String profileName, ParcelFileDescriptor profileFd,
-            boolean autoStopProfiler, Bundle testArguments,
-            IInstrumentationWatcher testWatcher, int debugMode, boolean restrictedBackupMode,
+            boolean autoStopProfiler, Bundle testArguments, IInstrumentationWatcher testWatcher,
+            int debugMode, boolean restrictedBackupMode, boolean persistent,
             Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services,
             Bundle coreSettings) throws RemoteException;
     void scheduleExit() throws RemoteException;
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index 316c474..48d0203 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -127,7 +127,7 @@
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
             BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
-            if (!device.equals(mDevice)) return;
+            if (device == null || !device.equals(mDevice)) return;
 
             if (action.equals(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)) {
                 int newState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, 0);
diff --git a/core/java/android/bluetooth/BluetoothProfileState.java b/core/java/android/bluetooth/BluetoothProfileState.java
index 98afdb8..b0c0a0b 100644
--- a/core/java/android/bluetooth/BluetoothProfileState.java
+++ b/core/java/android/bluetooth/BluetoothProfileState.java
@@ -59,7 +59,9 @@
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
             BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
-
+            if (device == null) {
+                return;
+            }
             if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) {
                 int newState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, 0);
                 if (mProfile == HFP && (newState == BluetoothProfile.STATE_CONNECTED ||
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index 1fcde3d..23d1b0f 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -94,6 +94,13 @@
      */
     public static boolean sRendererDisabled = false;
 
+    /**
+     * Further hardware renderer disabling for the system process.
+     * 
+     * @hide
+     */
+    public static boolean sSystemRendererDisabled = false;
+
     private boolean mEnabled;
     private boolean mRequested = true;
 
@@ -102,8 +109,11 @@
      * 
      * @hide
      */
-    public static void disable() {
+    public static void disable(boolean system) {
         sRendererDisabled = true;
+        if (system) {
+            sSystemRendererDisabled = true;
+        }
     }
 
     /**
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 7db1b32..0d160a9 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -584,16 +584,25 @@
                 return;
             }
 
-            // Only enable hardware acceleration if we are not in the system process
-            // The window manager creates ViewAncestors to display animated preview windows
-            // of launching apps and we don't want those to be hardware accelerated
+            // Persistent processes (including the system) should not do
+            // accelerated rendering on low-end devices.  In that case,
+            // sRendererDisabled will be set.  In addition, the system process
+            // itself should never do accelerated rendering.  In that case, both
+            // sRendererDisabled and sSystemRendererDisabled are set.  When
+            // sSystemRendererDisabled is set, PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED
+            // can be used by code on the system process to escape that and enable
+            // HW accelerated drawing.  (This is basically for the lock screen.)
 
-            final boolean systemHwAccelerated =
-                (attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED_SYSTEM) != 0;
+            final boolean fakeHwAccelerated = (attrs.privateFlags &
+                    WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED) != 0;
+            final boolean forceHwAccelerated = (attrs.privateFlags &
+                    WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED) != 0;
 
-            if (!HardwareRenderer.sRendererDisabled || systemHwAccelerated) {
+            if (!HardwareRenderer.sRendererDisabled || (HardwareRenderer.sSystemRendererDisabled
+                    && forceHwAccelerated)) {
                 // Don't enable hardware acceleration when we're not on the main thread
-                if (!systemHwAccelerated && Looper.getMainLooper() != Looper.myLooper()) {
+                if (!HardwareRenderer.sSystemRendererDisabled
+                        && Looper.getMainLooper() != Looper.myLooper()) {
                     Log.w(HardwareRenderer.LOG_TAG, "Attempting to initialize hardware "
                             + "acceleration outside of the main thread, aborting");
                     return;
@@ -606,12 +615,12 @@
                 mAttachInfo.mHardwareRenderer = HardwareRenderer.createGlRenderer(2, translucent);
                 mAttachInfo.mHardwareAccelerated = mAttachInfo.mHardwareAccelerationRequested
                         = mAttachInfo.mHardwareRenderer != null;
-            } else {
-                // We would normally have enabled hardware acceleration, but
-                // haven't because we are in the system process.  We still want
-                // what is drawn on the screen to behave as if it is accelerated,
-                // so that our preview starting windows visually match what will
-                // actually be drawn by the app.
+            } else if (fakeHwAccelerated) {
+                // The window had wanted to use hardware acceleration, but this
+                // is not allowed in its process.  By setting this flag, it can
+                // still render as if it was accelerated.  This is basically for
+                // the preview windows the window manager shows for launching
+                // applications, so they will look more like the app being launched.
                 mAttachInfo.mHardwareAccelerationRequested = true;
             }
         }
@@ -1599,6 +1608,11 @@
                 }
             }
         } else {
+            // If we're not drawing, then we don't need to draw the transitions, either
+            if (mPendingTransitions != null) {
+                mPendingTransitions.clear();
+            }
+
             // We were supposed to report when we are done drawing. Since we canceled the
             // draw, remember it here.
             if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 52d25d9..fb31e7d 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -412,12 +412,6 @@
          * End of types of system windows.
          */
         public static final int LAST_SYSTEM_WINDOW      = 2999;
-        
-        /**
-         * @deprecated this is ignored
-         */
-        @Deprecated
-        public int memoryType;
 
         /** @deprecated this is ignored, this value is set automatically when needed. */
         @Deprecated
@@ -431,58 +425,12 @@
         /** @deprecated this is ignored, this value is set automatically when needed. */
         @Deprecated
         public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
-
+        
         /**
-         * Various behavioral options/flags.  Default is none.
-         * 
-         * @see #FLAG_BLUR_BEHIND
-         * @see #FLAG_DIM_BEHIND
-         * @see #FLAG_NOT_FOCUSABLE
-         * @see #FLAG_NOT_TOUCHABLE
-         * @see #FLAG_NOT_TOUCH_MODAL
-         * @see #FLAG_LAYOUT_IN_SCREEN
-         * @see #FLAG_DITHER
-         * @see #FLAG_KEEP_SCREEN_ON
-         * @see #FLAG_FULLSCREEN
-         * @see #FLAG_FORCE_NOT_FULLSCREEN
-         * @see #FLAG_IGNORE_CHEEK_PRESSES
-         * @see #FLAG_HARDWARE_ACCELERATED
+         * @deprecated this is ignored
          */
-        @ViewDebug.ExportedProperty(flagMapping = {
-            @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
-                    name = "FLAG_BLUR_BEHIND"),
-            @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
-                    name = "FLAG_DIM_BEHIND"),
-            @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
-                    name = "FLAG_NOT_FOCUSABLE"),
-            @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
-                    name = "FLAG_NOT_TOUCHABLE"),
-            @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
-                    name = "FLAG_NOT_TOUCH_MODAL"),
-            @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
-                    name = "FLAG_LAYOUT_IN_SCREEN"),
-            @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
-                    name = "FLAG_DITHER"),
-            @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
-                    name = "FLAG_TURN_SCREEN_ON"),
-            @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
-                    name = "FLAG_KEEP_SCREEN_ON"),
-            @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
-                    name = "FLAG_SHOW_WHEN_LOCKED"),
-            @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
-                    name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
-            @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
-                    name = "FLAG_DISMISS_KEYGUARD"),
-            @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
-                    name = "FLAG_FULLSCREEN"),
-            @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN,
-                    equals = FLAG_FORCE_NOT_FULLSCREEN, name = "FLAG_FORCE_NOT_FULLSCREEN"),
-            @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES,
-                    equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES"),
-            @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED,
-                    equals = FLAG_HARDWARE_ACCELERATED, name = "FLAG_HARDWARE_ACCELERATED")
-        })
-        public int flags;
+        @Deprecated
+        public int memoryType;
         
         /** Window flag: as long as this window is visible to the user, allow
          *  the lock screen to activate while the screen is on. 
@@ -493,10 +441,12 @@
         /** Window flag: everything behind this window will be dimmed.
          *  Use {@link #dimAmount} to control the amount of dim. */
         public static final int FLAG_DIM_BEHIND        = 0x00000002;
-        
-        /** Window flag: blur everything behind this window. */
+
+        /** Window flag: blur everything behind this window.
+         * @deprecated Blurring is no longer supported. */
+        @Deprecated
         public static final int FLAG_BLUR_BEHIND        = 0x00000004;
-        
+
         /** Window flag: this window won't ever get key input focus, so the
          * user can not send key or other button events to it.  Those will
          * instead go to whatever focusable window is behind it.  This flag
@@ -686,17 +636,6 @@
          * XML attribute is set to true on an activity or on the application.</p>
          */
         public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
-        
-        /**
-         * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
-         * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
-         * is generally disabled. This flag must be specified in addition to 
-         * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
-         * windows.
-         * 
-         * @hide
-         */
-        public static final int FLAG_HARDWARE_ACCELERATED_SYSTEM = 0x02000000;
 
         // ----- HIDDEN FLAGS.
         // These start at the high bit and go down.
@@ -747,6 +686,125 @@
         public static final int FLAG_SYSTEM_ERROR = 0x40000000;
 
         /**
+         * Various behavioral options/flags.  Default is none.
+         * 
+         * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
+         * @see #FLAG_DIM_BEHIND
+         * @see #FLAG_NOT_FOCUSABLE
+         * @see #FLAG_NOT_TOUCHABLE
+         * @see #FLAG_NOT_TOUCH_MODAL
+         * @see #FLAG_TOUCHABLE_WHEN_WAKING
+         * @see #FLAG_KEEP_SCREEN_ON
+         * @see #FLAG_LAYOUT_IN_SCREEN
+         * @see #FLAG_LAYOUT_NO_LIMITS
+         * @see #FLAG_FULLSCREEN
+         * @see #FLAG_FORCE_NOT_FULLSCREEN
+         * @see #FLAG_DITHER
+         * @see #FLAG_SECURE
+         * @see #FLAG_SCALED
+         * @see #FLAG_IGNORE_CHEEK_PRESSES
+         * @see #FLAG_LAYOUT_INSET_DECOR
+         * @see #FLAG_ALT_FOCUSABLE_IM
+         * @see #FLAG_WATCH_OUTSIDE_TOUCH
+         * @see #FLAG_SHOW_WHEN_LOCKED
+         * @see #FLAG_SHOW_WALLPAPER
+         * @see #FLAG_TURN_SCREEN_ON
+         * @see #FLAG_DISMISS_KEYGUARD
+         * @see #FLAG_SPLIT_TOUCH
+         * @see #FLAG_HARDWARE_ACCELERATED
+         */
+        @ViewDebug.ExportedProperty(flagMapping = {
+            @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
+                    name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
+            @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
+                    name = "FLAG_DIM_BEHIND"),
+            @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
+                    name = "FLAG_BLUR_BEHIND"),
+            @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
+                    name = "FLAG_NOT_FOCUSABLE"),
+            @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
+                    name = "FLAG_NOT_TOUCHABLE"),
+            @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
+                    name = "FLAG_NOT_TOUCH_MODAL"),
+            @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
+                    name = "FLAG_TOUCHABLE_WHEN_WAKING"),
+            @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
+                    name = "FLAG_KEEP_SCREEN_ON"),
+            @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
+                    name = "FLAG_LAYOUT_IN_SCREEN"),
+            @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
+                    name = "FLAG_LAYOUT_NO_LIMITS"),
+            @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
+                    name = "FLAG_FULLSCREEN"),
+            @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
+                    name = "FLAG_FORCE_NOT_FULLSCREEN"),
+            @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
+                    name = "FLAG_DITHER"),
+            @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
+                    name = "FLAG_SECURE"),
+            @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
+                    name = "FLAG_SCALED"),
+            @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
+                    name = "FLAG_IGNORE_CHEEK_PRESSES"),
+            @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
+                    name = "FLAG_LAYOUT_INSET_DECOR"),
+            @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
+                    name = "FLAG_ALT_FOCUSABLE_IM"),
+            @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
+                    name = "FLAG_WATCH_OUTSIDE_TOUCH"),
+            @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
+                    name = "FLAG_SHOW_WHEN_LOCKED"),
+            @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
+                    name = "FLAG_SHOW_WALLPAPER"),
+            @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
+                    name = "FLAG_TURN_SCREEN_ON"),
+            @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
+                    name = "FLAG_DISMISS_KEYGUARD"),
+            @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
+                    name = "FLAG_SPLIT_TOUCH"),
+            @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
+                    name = "FLAG_HARDWARE_ACCELERATED")
+        })
+        public int flags;
+
+        /**
+         * If the window has requested hardware acceleration, but this is not
+         * allowed in the process it is in, then still render it as if it is
+         * hardware accelerated.  This is used for the starting preview windows
+         * in the system process, which don't need to have the overhead of
+         * hardware acceleration (they are just a static rendering), but should
+         * be rendered as much to match the actual window of the app even if it
+         * is hardware accelerated.
+         * Even if the window isn't hardware accelerated, still do its rendering
+         * as if it is.
+         * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
+         * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
+         * is generally disabled. This flag must be specified in addition to 
+         * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
+         * windows.
+         * 
+         * @hide
+         */
+        public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
+
+        /**
+         * In the system process, we globally do not use hardware acceleration
+         * because there are many threads doing UI there and they an conflict.
+         * If certain parts of the UI that really do want to use hardware
+         * acceleration, this flag can be set to force it.  This is basically
+         * for the lock screen.  Anyone else using it, you are probably wrong.
+         * 
+         * @hide
+         */
+        public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
+
+        /**
+         * Control flags that are private to the platform.
+         * @hide
+         */
+        public int privateFlags;
+
+        /**
          * Given a particular set of window manager flags, determine whether
          * such a window may be a target for an input method when it has
          * focus.  In particular, this checks the
@@ -1110,6 +1168,7 @@
             out.writeInt(y);
             out.writeInt(type);
             out.writeInt(flags);
+            out.writeInt(privateFlags);
             out.writeInt(softInputMode);
             out.writeInt(gravity);
             out.writeFloat(horizontalMargin);
@@ -1149,6 +1208,7 @@
             y = in.readInt();
             type = in.readInt();
             flags = in.readInt();
+            privateFlags = in.readInt();
             softInputMode = in.readInt();
             gravity = in.readInt();
             horizontalMargin = in.readFloat();
@@ -1190,6 +1250,8 @@
         public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14;
         /** {@hide} */
         public static final int INPUT_FEATURES_CHANGED = 1<<15;
+        /** {@hide} */
+        public static final int PRIVATE_FLAGS_CHANGED = 1<<16;
     
         // internal buffer to backup/restore parameters under compatibility mode.
         private int[] mCompatibilityParamsBackup = null;
@@ -1237,6 +1299,10 @@
                 flags = o.flags;
                 changes |= FLAGS_CHANGED;
             }
+            if (privateFlags != o.privateFlags) {
+                privateFlags = o.privateFlags;
+                changes |= PRIVATE_FLAGS_CHANGED;
+            }
             if (softInputMode != o.softInputMode) {
                 softInputMode = o.softInputMode;
                 changes |= SOFT_INPUT_MODE_CHANGED;
@@ -1353,6 +1419,9 @@
             sb.append(type);
             sb.append(" fl=#");
             sb.append(Integer.toHexString(flags));
+            if (privateFlags != 0) {
+                sb.append(" pfl=0x").append(Integer.toHexString(privateFlags));
+            }
             if (format != PixelFormat.OPAQUE) {
                 sb.append(" fmt=");
                 sb.append(format);
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 133f435..5a97317 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -3384,11 +3384,11 @@
     protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
         super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
 
+        final ListAdapter adapter = mAdapter;
         int closetChildIndex = -1;
-        if (gainFocus && previouslyFocusedRect != null) {
+        if (adapter != null && gainFocus && previouslyFocusedRect != null) {
             previouslyFocusedRect.offset(mScrollX, mScrollY);
 
-            final ListAdapter adapter = mAdapter;
             // Don't cache the result of getChildCount or mFirstPosition here,
             // it could change in layoutChildren.
             if (adapter.getCount() < getChildCount() + mFirstPosition) {
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index b2c3051..e033d2d 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -933,9 +933,32 @@
         // onDraw will translate the canvas so we draw starting at 0,0
         int right = w - mPaddingRight - mPaddingLeft;
         int bottom = h - mPaddingBottom - mPaddingTop;
+        int top = 0;
+        int left = 0;
 
         if (mIndeterminateDrawable != null) {
-            mIndeterminateDrawable.setBounds(0, 0, right, bottom);
+            if (mOnlyIndeterminate) {
+                // Maintain aspect ratio. Certain kinds of animated drawables
+                // get very confused otherwise.
+                final int intrinsicWidth = mIndeterminateDrawable.getIntrinsicWidth();
+                final int intrinsicHeight = mIndeterminateDrawable.getIntrinsicHeight();
+                final float intrinsicAspect = (float) intrinsicWidth / intrinsicHeight;
+                final float boundAspect = (float) w / h;
+                if (intrinsicAspect != boundAspect) {
+                    if (boundAspect > intrinsicAspect) {
+                        // New width is larger. Make it smaller to match height.
+                        final int width = (int) (h * intrinsicAspect);
+                        left = (w - width) / 2;
+                        right = left + width;
+                    } else {
+                        // New height is larger. Make it smaller to match width.
+                        final int height = (int) (w * (1 / intrinsicAspect));
+                        top = (h - height) / 2;
+                        bottom = top + height;
+                    }
+                }
+            }
+            mIndeterminateDrawable.setBounds(left, top, right, bottom);
         }
         
         if (mProgressDrawable != null) {
diff --git a/graphics/java/android/graphics/drawable/RotateDrawable.java b/graphics/java/android/graphics/drawable/RotateDrawable.java
index 4f74b37..e987679 100644
--- a/graphics/java/android/graphics/drawable/RotateDrawable.java
+++ b/graphics/java/android/graphics/drawable/RotateDrawable.java
@@ -83,7 +83,7 @@
         float px = st.mPivotXRel ? (w * st.mPivotX) : st.mPivotX;
         float py = st.mPivotYRel ? (h * st.mPivotY) : st.mPivotY;
 
-        canvas.rotate(st.mCurrentDegrees, px, py);
+        canvas.rotate(st.mCurrentDegrees, px + bounds.left, py + bounds.top);
 
         st.mDrawable.draw(canvas);
 
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index 710ef94..0bee0f1 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -219,9 +219,12 @@
     if (i < 0) {
         return i;
     }
-    mSurfaceTexture->queueBuffer(i, timestamp,
+    status_t err = mSurfaceTexture->queueBuffer(i, timestamp,
             &mDefaultWidth, &mDefaultHeight, &mTransformHint);
-    return OK;
+    if (err != OK)  {
+        LOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err);
+    }
+    return err;
 }
 
 int SurfaceTextureClient::query(int what, int* value) const {
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index cd15718..d233f92 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -2295,7 +2295,13 @@
                 int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
                                                BluetoothProfile.STATE_DISCONNECTED);
                 BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+                if (btDevice == null) {
+                    return;
+                }
                 String address = btDevice.getAddress();
+                if (!BluetoothAdapter.checkBluetoothAddress(address)) {
+                    address = "";
+                }
                 boolean isConnected =
                     (mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) &&
                      mConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP).equals(address));
@@ -2331,24 +2337,30 @@
                 int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
                                                BluetoothProfile.STATE_DISCONNECTED);
                 int device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO;
-                BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                 String address = null;
-                if (btDevice != null) {
-                    address = btDevice.getAddress();
-                    BluetoothClass btClass = btDevice.getBluetoothClass();
-                    if (btClass != null) {
-                        switch (btClass.getDeviceClass()) {
-                        case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
-                        case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
-                            device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
-                            break;
-                        case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
-                            device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
-                            break;
-                        }
+
+                BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+                if (btDevice == null) {
+                    return;
+                }
+
+                address = btDevice.getAddress();
+                BluetoothClass btClass = btDevice.getBluetoothClass();
+                if (btClass != null) {
+                    switch (btClass.getDeviceClass()) {
+                    case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
+                    case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
+                        device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
+                        break;
+                    case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
+                        device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
+                        break;
                     }
                 }
 
+                if (!BluetoothAdapter.checkBluetoothAddress(address)) {
+                    address = "";
+                }
                 boolean isConnected = (mConnectedDevices.containsKey(device) &&
                                        mConnectedDevices.get(device).equals(address));
 
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 853a5f6..7b14c18 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -511,9 +511,15 @@
                                                const char *device_address)
 {
     const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+    const char *address = "";
+
     if (aps == 0) return PERMISSION_DENIED;
 
-    return aps->setDeviceConnectionState(device, state, device_address);
+    if (device_address != NULL) {
+        address = device_address;
+    }
+
+    return aps->setDeviceConnectionState(device, state, address);
 }
 
 audio_policy_dev_state_t AudioSystem::getDeviceConnectionState(audio_devices_t device,
diff --git a/packages/SystemUI/res/layout/status_bar_notification_row.xml b/packages/SystemUI/res/layout/status_bar_notification_row.xml
index d627dc4..ff86878 100644
--- a/packages/SystemUI/res/layout/status_bar_notification_row.xml
+++ b/packages/SystemUI/res/layout/status_bar_notification_row.xml
@@ -22,6 +22,7 @@
         android:layout_alignParentTop="true"
         android:layout_alignParentLeft="true"
         android:scaleType="center"
+        android:clickable="true"
         />
 
     <com.android.systemui.statusbar.LatestItemView android:id="@+id/content"
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
index 85cde7c..5c1bbf0d 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
@@ -26,6 +26,7 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewConfiguration;
+import android.view.View.OnClickListener;
 import android.widget.HorizontalScrollView;
 import android.widget.LinearLayout;
 
@@ -75,13 +76,23 @@
                 mPerformanceHelper.addViewCallback(view);
             }
 
-            final View thumbnail = view.findViewById(R.id.app_thumbnail);
-            // thumbnail is set to clickable in the layout file
-            thumbnail.setOnClickListener(new OnClickListener() {
+            view.setOnClickListener(new OnClickListener() {
+                public void onClick(View v) {
+                    mCallback.dismiss();
+                }
+            });
+
+            OnClickListener launchAppListener = new OnClickListener() {
                 public void onClick(View v) {
                     mCallback.handleOnClick(view);
                 }
-            });
+            };
+            final View thumbnail = view.findViewById(R.id.app_thumbnail);
+            thumbnail.setClickable(true);
+            thumbnail.setOnClickListener(launchAppListener);
+            final View appTitle = view.findViewById(R.id.app_label);
+            appTitle.setClickable(true);
+            appTitle.setOnClickListener(launchAppListener);
             mLinearLayout.addView(view);
         }
         // Scroll to end after layout.
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index d7bb3c4..fc33931 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -84,7 +84,7 @@
     private View mRecentsScrim;
     private View mRecentsGlowView;
     private ViewGroup mRecentsContainer;
-    private Bitmap mAppThumbnailBackground;
+    private Bitmap mDefaultThumbnailBackground;
 
     private boolean mShowing;
     private Choreographer mChoreo;
@@ -125,7 +125,7 @@
         }
 
         public void setThumbnail(Bitmap thumbnail) {
-            mThumbnail = compositeBitmap(mAppThumbnailBackground, thumbnail);
+            mThumbnail = compositeBitmap(mDefaultThumbnailBackground, thumbnail);
         }
 
         public Bitmap getThumbnail() {
@@ -339,8 +339,8 @@
         int width = (int) res.getDimension(R.dimen.status_bar_recents_thumbnail_width);
         int height = (int) res.getDimension(R.dimen.status_bar_recents_thumbnail_height);
         int color = res.getColor(R.drawable.status_bar_recents_app_thumbnail_background);
-        mAppThumbnailBackground = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
-        Canvas c = new Canvas(mAppThumbnailBackground);
+        mDefaultThumbnailBackground = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+        Canvas c = new Canvas(mDefaultThumbnailBackground);
         c.drawColor(color);
     }
 
@@ -517,7 +517,7 @@
         synchronized (ad) {
             ad.mLabel = label;
             ad.mIcon = icon;
-            ad.setThumbnail(thumbs != null ? thumbs.mainThumbnail : null);
+            ad.setThumbnail(thumbs != null ? thumbs.mainThumbnail : mDefaultThumbnailBackground);
         }
     }
 
@@ -577,7 +577,7 @@
         }
         mActivityDescriptions = getRecentTasks();
         for (ActivityDescription ad : mActivityDescriptions) {
-            ad.setThumbnail(mAppThumbnailBackground);
+            ad.setThumbnail(mDefaultThumbnailBackground);
         }
         mListAdapter.notifyDataSetInvalidated();
         if (mActivityDescriptions.size() > 0) {
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index fe255cb..3fa3078 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -232,7 +232,6 @@
                 WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY,
                 WindowManager.LayoutParams.FLAG_FULLSCREEN
                     | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
-                    | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED_SYSTEM
                     | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                     | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED,
                 PixelFormat.TRANSLUCENT);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 3d23abe..8be250b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -662,9 +662,12 @@
                 // update the contentIntent
                 final PendingIntent contentIntent = notification.notification.contentIntent;
                 if (contentIntent != null) {
-                    oldEntry.content.setOnClickListener(new NotificationClicker(contentIntent,
-                                notification.pkg, notification.tag, notification.id));
+                    final View.OnClickListener listener = new NotificationClicker(contentIntent,
+                            notification.pkg, notification.tag, notification.id);
+                    oldEntry.largeIcon.setOnClickListener(listener);
+                    oldEntry.content.setOnClickListener(listener);
                 } else {
+                    oldEntry.largeIcon.setOnClickListener(null);
                     oldEntry.content.setOnClickListener(null);
                 }
                 // Update the icon.
@@ -779,9 +782,12 @@
         content.setOnFocusChangeListener(mFocusChangeListener);
         PendingIntent contentIntent = n.contentIntent;
         if (contentIntent != null) {
-            content.setOnClickListener(new NotificationClicker(contentIntent, notification.pkg,
-                        notification.tag, notification.id));
+            final View.OnClickListener listener = new NotificationClicker(contentIntent,
+                    notification.pkg, notification.tag, notification.id);
+            largeIcon.setOnClickListener(listener);
+            content.setOnClickListener(listener);
         } else {
+            largeIcon.setOnClickListener(null);
             content.setOnClickListener(null);
         }
 
@@ -979,9 +985,12 @@
 //        content.setOnFocusChangeListener(mFocusChangeListener);
         PendingIntent contentIntent = sbn.notification.contentIntent;
         if (contentIntent != null) {
-            content.setOnClickListener(new NotificationClicker(contentIntent,
-                        sbn.pkg, sbn.tag, sbn.id));
+            final View.OnClickListener listener = new NotificationClicker(contentIntent,
+                    sbn.pkg, sbn.tag, sbn.id);
+            largeIcon.setOnClickListener(listener);
+            content.setOnClickListener(listener);
         } else {
+            largeIcon.setOnClickListener(null);
             content.setOnClickListener(null);
         }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
index 4a1cafd..510fd3b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
@@ -147,7 +147,7 @@
         public boolean onPreDraw() {
             getViewTreeObserver().removeOnPreDrawListener(this);
             mChoreo.startAnimation(true);
-            return true;
+            return false;
         }
     };
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index cc73d7b..b4c480b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -838,9 +838,12 @@
                 // update the contentIntent
                 final PendingIntent contentIntent = notification.notification.contentIntent;
                 if (contentIntent != null) {
-                    oldEntry.content.setOnClickListener(new NotificationClicker(contentIntent,
-                                notification.pkg, notification.tag, notification.id));
+                    final View.OnClickListener listener = new NotificationClicker(contentIntent,
+                            notification.pkg, notification.tag, notification.id);
+                    oldEntry.largeIcon.setOnClickListener(listener);
+                    oldEntry.content.setOnClickListener(listener);
                 } else {
+                    oldEntry.largeIcon.setOnClickListener(null);
                     oldEntry.content.setOnClickListener(null);
                 }
                 // Update the icon.
@@ -1766,9 +1769,12 @@
 //        content.setOnFocusChangeListener(mFocusChangeListener);
         PendingIntent contentIntent = sbn.notification.contentIntent;
         if (contentIntent != null) {
-            content.setOnClickListener(new NotificationClicker(contentIntent,
-                        sbn.pkg, sbn.tag, sbn.id));
+            final View.OnClickListener listener = new NotificationClicker(
+                    contentIntent, sbn.pkg, sbn.tag, sbn.id);
+            largeIcon.setOnClickListener(listener);
+            content.setOnClickListener(listener);
         } else {
+            largeIcon.setOnClickListener(null);
             content.setOnClickListener(null);
         }
 
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
index f52bb26..c1f1151 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
@@ -115,15 +115,19 @@
             }
             if (ActivityManager.isHighEndGfx(((WindowManager)mContext.getSystemService(
                     Context.WINDOW_SERVICE)).getDefaultDisplay())) {
-                flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
-                        | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED_SYSTEM;
+                flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
             }
             WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                     stretch, stretch, WindowManager.LayoutParams.TYPE_KEYGUARD,
                     flags, PixelFormat.TRANSLUCENT);
             lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
             lp.windowAnimations = com.android.internal.R.style.Animation_LockScreen;
-
+            if (ActivityManager.isHighEndGfx(((WindowManager)mContext.getSystemService(
+                    Context.WINDOW_SERVICE)).getDefaultDisplay())) {
+                lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
+                lp.privateFlags |=
+                        WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
+            }
             lp.setTitle("Keyguard");
             mWindowLayoutParams = lp;
 
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 2f5deba..304df72 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -1226,6 +1226,8 @@
             params.packageName = packageName;
             params.windowAnimations = win.getWindowStyle().getResourceId(
                     com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
+            params.privateFlags |=
+                    WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED;
             params.setTitle("Starting " + packageName);
 
             WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java
index f5fd6bd..9f4936df 100644
--- a/services/java/com/android/server/AppWidgetService.java
+++ b/services/java/com/android/server/AppWidgetService.java
@@ -170,6 +170,7 @@
     final ArrayList<AppWidgetId> mAppWidgetIds = new ArrayList<AppWidgetId>();
     ArrayList<Host> mHosts = new ArrayList<Host>();
     boolean mSafeMode;
+    boolean mStateLoaded;
 
     AppWidgetService(Context context) {
         mContext = context;
@@ -180,8 +181,9 @@
     public void systemReady(boolean safeMode) {
         mSafeMode = safeMode;
 
-        loadAppWidgetList();
-        loadStateLocked();
+        synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
+        }
 
         // Register for the boot completed broadcast, so we can send the
         // ENABLE broacasts.  If we try to send them now, they time out,
@@ -209,6 +211,14 @@
         mContext.registerReceiver(mBroadcastReceiver, sdFilter);
     }
 
+    private void ensureStateLoadedLocked() {
+        if (!mStateLoaded) {
+            loadAppWidgetList();
+            loadStateLocked();
+            mStateLoaded = true;
+        }
+    }
+
     @Override
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
         if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
@@ -285,6 +295,7 @@
     public int allocateAppWidgetId(String packageName, int hostId) {
         int callingUid = enforceCallingUid(packageName);
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             int appWidgetId = mNextAppWidgetId++;
 
             Host host = lookupOrAddHostLocked(callingUid, packageName, hostId);
@@ -304,6 +315,7 @@
 
     public void deleteAppWidgetId(int appWidgetId) {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
             if (id != null) {
                 deleteAppWidgetLocked(id);
@@ -314,6 +326,7 @@
 
     public void deleteHost(int hostId) {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             int callingUid = getCallingUid();
             Host host = lookupHostLocked(callingUid, hostId);
             if (host != null) {
@@ -325,6 +338,7 @@
 
     public void deleteAllHosts() {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             int callingUid = getCallingUid();
             final int N = mHosts.size();
             boolean changed = false;
@@ -405,6 +419,7 @@
         final long ident = Binder.clearCallingIdentity();
         try {
             synchronized (mAppWidgetIds) {
+                ensureStateLoadedLocked();
                 AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
                 if (id == null) {
                     throw new IllegalArgumentException("bad appWidgetId");
@@ -448,6 +463,7 @@
     // Binds to a specific RemoteViewsService
     public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection) {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
             if (id == null) {
                 throw new IllegalArgumentException("bad appWidgetId");
@@ -499,6 +515,7 @@
     // Unbinds from a specific RemoteViewsService
     public void unbindRemoteViewsService(int appWidgetId, Intent intent) {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             // Unbind from the RemoteViewsService (which will trigger a callback to the bound
             // RemoteViewsAdapter)
             Pair<Integer, FilterComparison> key = Pair.create(appWidgetId,
@@ -610,6 +627,7 @@
 
     public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId) {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
             if (id != null && id.provider != null && !id.provider.zombie) {
                 return id.provider.info;
@@ -620,6 +638,7 @@
 
     public RemoteViews getAppWidgetViews(int appWidgetId) {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
             if (id != null) {
                 return id.views;
@@ -630,6 +649,7 @@
 
     public List<AppWidgetProviderInfo> getInstalledProviders() {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             final int N = mInstalledProviders.size();
             ArrayList<AppWidgetProviderInfo> result = new ArrayList<AppWidgetProviderInfo>(N);
             for (int i=0; i<N; i++) {
@@ -652,6 +672,7 @@
         final int N = appWidgetIds.length;
 
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             for (int i=0; i<N; i++) {
                 AppWidgetId id = lookupAppWidgetIdLocked(appWidgetIds[i]);
                 updateAppWidgetInstanceLocked(id, views);
@@ -669,6 +690,7 @@
         final int N = appWidgetIds.length;
 
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             for (int i=0; i<N; i++) {
                 AppWidgetId id = lookupAppWidgetIdLocked(appWidgetIds[i]);
                 updateAppWidgetInstanceLocked(id, views, true);
@@ -686,6 +708,7 @@
         final int N = appWidgetIds.length;
 
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             for (int i=0; i<N; i++) {
                 AppWidgetId id = lookupAppWidgetIdLocked(appWidgetIds[i]);
                 notifyAppWidgetViewDataChangedInstanceLocked(id, viewId);
@@ -695,6 +718,7 @@
 
     public void updateAppWidgetProvider(ComponentName provider, RemoteViews views) {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             Provider p = lookupProviderLocked(provider);
             if (p == null) {
                 Slog.w(TAG, "updateAppWidgetProvider: provider doesn't exist: " + provider);
@@ -759,6 +783,7 @@
             List<RemoteViews> updatedViews) {
         int callingUid = enforceCallingUid(packageName);
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             Host host = lookupOrAddHostLocked(callingUid, packageName, hostId);
             host.callbacks = callbacks;
 
@@ -778,6 +803,7 @@
 
     public void stopListening(int hostId) {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             Host host = lookupHostLocked(getCallingUid(), hostId);
             if (host != null) {
                 host.callbacks = null;
@@ -965,6 +991,7 @@
     
     public int[] getAppWidgetIds(ComponentName provider) {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             Provider p = lookupProviderLocked(provider);
             if (p != null && getCallingUid() == p.uid) {
                 return getAppWidgetIds(p);                
@@ -1087,6 +1114,7 @@
 
     void sendInitialBroadcasts() {
         synchronized (mAppWidgetIds) {
+            ensureStateLoadedLocked();
             final int N = mInstalledProviders.size();
             for (int i=0; i<N; i++) {
                 Provider p = mInstalledProviders.get(i);
@@ -1391,6 +1419,7 @@
                     mLocale = revised;
 
                     synchronized (mAppWidgetIds) {
+                        ensureStateLoadedLocked();
                         int N = mInstalledProviders.size();
                         for (int i=N-1; i>=0; i--) {
                             Provider p = mInstalledProviders.get(i);
@@ -1428,6 +1457,7 @@
                 }
                 if (added || changed) {
                     synchronized (mAppWidgetIds) {
+                        ensureStateLoadedLocked();
                         Bundle extras = intent.getExtras();
                         if (changed || (extras != null &&
                                     extras.getBoolean(Intent.EXTRA_REPLACING, false))) {
@@ -1449,6 +1479,7 @@
                         // The package is being updated.  We'll receive a PACKAGE_ADDED shortly.
                     } else {
                         synchronized (mAppWidgetIds) {
+                            ensureStateLoadedLocked();
                             for (String pkgName : pkgList) {
                                 removeProvidersForPackageLocked(pkgName);
                                 saveStateLocked();
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index bb5e989..9db56ce 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -3598,7 +3598,7 @@
             thread.bindApplication(processName, appInfo, providers,
                     app.instrumentationClass, profileFile, profileFd, profileAutoStop,
                     app.instrumentationArguments, app.instrumentationWatcher, testMode, 
-                    isRestrictedBackupMode || !normalMode,
+                    isRestrictedBackupMode || !normalMode, app.persistent,
                     mConfiguration, app.compat, getCommonServicesLocked(),
                     mCoreSettingsObserver.getCoreSettingsLocked());
             updateLruProcessLocked(app, false, true);