Add android:hardwareAccelerated to Activity.

Hardware acceleration can now be enabled/disabled locally on each activity
declared in the manifest. It can also be enabled/disabled directly on a
window through the WindowManager.LayoutParams.

Change-Id: I91dd0b26c4e7eb8cd7288e523ed6b7bda6d0990b
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 877a302..8abbf58 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -16,7 +16,6 @@
 
 package android.view;
 
-import android.content.pm.ApplicationInfo;
 import com.android.internal.view.BaseSurfaceHolder;
 import com.android.internal.view.IInputMethodCallback;
 import com.android.internal.view.IInputMethodSession;
@@ -329,7 +328,7 @@
                 mWindowAttributes.copyFrom(attrs);
                 attrs = mWindowAttributes;
                 
-                enableHardwareAcceleration(view, attrs);
+                enableHardwareAcceleration(attrs);
 
                 if (view instanceof RootViewSurfaceTaker) {
                     mSurfaceHolderCallback =
@@ -460,14 +459,14 @@
         }
     }
 
-    private void enableHardwareAcceleration(View view, WindowManager.LayoutParams attrs) {
+    private void enableHardwareAcceleration(WindowManager.LayoutParams attrs) {
         // Only enable hardware acceleration if we are not in the system process
         // The window manager creates ViewRoots to display animated preview windows
         // of launching apps and we don't want those to be hardware accelerated
         if (Process.myUid() != Process.SYSTEM_UID) {
             // Try to enable hardware acceleration if requested
-            if ((view.getContext().getApplicationInfo().flags &
-                    ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
+            if (attrs != null &&
+                    (attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0) {
                 final boolean translucent = attrs.format != PixelFormat.OPAQUE;
                 mHwRenderer = HardwareRenderer.createGlRenderer(2, translucent);
             }